[JAVA-814] Unable to create a full text index on $** Created: 24/Apr/13  Updated: 21/Jun/13  Resolved: 05/Jun/13

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 2.11.0
Fix Version/s: 2.11.2, 2.12.0

Type: Improvement Priority: Major - P3
Reporter: Steve Briskin (Inactive) Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

There's an Exception where I try to create an FTS index on $**. FTS on regular fields (e.g.

{a:"text"}

) seems to work as expected.

Below was done with java driver commit 8ca48fafa84fdfa41e6b7e2d8bbca5cf8151fca8 on master.

        Mongo mongo = new MongoClient("localhost", 27000);
        DBCollection coll = mongo.getDB("test").getCollection("a");
        
        DBObject key = new BasicDBObject("$**", "text");
        coll.ensureIndex(key);       

Exception in thread "main" com.mongodb.MongoException: invalid operator: $**
	at com.mongodb.MongoException.parse(MongoException.java:82)
	at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:292)
	at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:273)
	at com.mongodb.DBCollection.findOne(DBCollection.java:728)
	at com.mongodb.DBCollection.findOne(DBCollection.java:670)
	at com.mongodb.DBApiLayer$MyCollection.createIndex(DBApiLayer.java:342)
	at com.mongodb.DBCollection.createIndex(DBCollection.java:485)
	at com.mongodb.DBCollection.ensureIndex(DBCollection.java:561)
	at com.mongodb.DBCollection.ensureIndex(DBCollection.java:512)
	at TestEnsureIndex.main(TestEnsureIndex.java:14)



 Comments   
Comment by auto [ 05/Jun/13 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-814: Remove findOne check for index existence in createIndex method. It's not necessary, and it causes an error on text indices on "$**" field.
Branch: 2.11.x
https://github.com/mongodb/mongo-java-driver/commit/d7999757246a1cd8cc4be0864bae62dc1b099b1d

Comment by Steve Briskin (Inactive) [ 26/Apr/13 ]

Tried the patch and it worked. Thanks.

Comment by auto [ 24/Apr/13 ]

Author:

{u'date': u'2013-04-24T17:24:59Z', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-814: Remove findOne check for index existence in createIndex method. It's not necessary, and it causes an error on text indices on "$**" field.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/14b1c1f1d91491290fd7986ed0470c853d871f0b

Comment by Jeffrey Yemin [ 24/Apr/13 ]

It's happening because the driver is issuing a findOne on "system.indexes" with a key that starts with "$", and the server is rejecting the query.

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