[SERVER-8127] Multiple text indexes per collection should not be allowed Created: 09/Jan/13  Updated: 11/Jul/16  Resolved: 10/Feb/14

Status: Closed
Project: Core Server
Component/s: Text Search
Affects Version/s: None
Fix Version/s: 2.6.0-rc0

Type: Bug Priority: Major - P3
Reporter: J Rassi Assignee: J Rassi
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-10925 Should forbid creating > 1 text index Closed
Operating System: ALL
Participants:

 Description   

Works as designed?

> db.foo.ensureIndex({a:"text"})
> db.foo.ensureIndex({b:"text"})
> db.foo.runCommand("text",{search:"word"})
{ "ok" : 0, "errmsg" : "too many text index for: test.foo" }
> 



 Comments   
Comment by Githook User [ 10/Feb/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-8127 IndexCatalog won't build text index if one already exists
Branch: master
https://github.com/mongodb/mongo/commit/5999bc487e0b5a80c26676f396ba2544d9fadd5d

Comment by Tobias Pfeiffer [ 09/Apr/13 ]

First of all, I think that if the "too many text index for" message is per design, then it should not be allowed to set more than one text index on one collection.

Anyway, I have the following use case for multiple text indexes per collection: My documents look like

{"_id": ..., "de":

{"body": ..., "title": ..., published: true|false}

, "en": {"body": ..., "title": ..., published: true|false}},

that is, I have two languages per document. I expected to be able to do the following:

db.contents.ensureIndex(

{"de.published": 1, "de.body": "text", "de.title": "text"}

,

{default_language: "german"}

)
db.contents.ensureIndex(

{"en.published": 1, "en.body": "text", "en.title": "text"}

,

{default_language: "english"}

)

and then find a content using

db.contents.runCommand("text", {search: "some term", language: "german", filter: {"de.published": true}})

but this gives the exact error message from above. I think it would be great if one could have one text index per collection and language. What do you think?

Generated at Thu Feb 08 03:16:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.