0

Could any one, please tell me how to do -

Indexing and Searching an "array" type within an embedded document in MongoDB using Java.

For example: The outer document id UserDetails and the array is given below

"languages_known" : 
          [ 
             "English", 
             "Kannada",
             "Hindi",
             "German" 
          ]

I referred this : http://docs.mongodb.org/manual/core/index-multikey/#index-type-multikey. But still I could not do.

Please tell to do Indexing and Searching for the above in Java.

1 Answer 1

1

You build an index on array inside a document using below in mongo shell:-

db.collection_name.ensureIndex({languages_known: 1}) // In your case

In java driver you can use:-

collection.createIndex(DBObject keys);

Can you please clarify what did you try and errors that you may have encountered?

Sign up to request clarification or add additional context in comments.

2 Comments

I could able to do this using below link: stackoverflow.com/questions/24630599/…
Could you please give a solution to the problem. The link is : stackoverflow.com/questions/24690620/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.