[SERVER-41591] Custom index Created: 09/Jun/19  Updated: 17/Jun/19  Resolved: 17/Jun/19

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: None

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

Participants:

 Description   

Some times, we need indexing of type:

index each value of "attr1" + any document with value "attr2='ccc'"

 

{
    $or:[ {attr1: 1}, {attr2: 'static value'}]
}

In general, we need to customise indexing behaviour. (using predicats or function) 

 



 Comments   
Comment by Danny Hatcher (Inactive) [ 17/Jun/19 ]

The SERVER project is for bugs and feature suggestions for the MongoDB server. If you need assistance on designing optimal indexes for your use case, I encourage you to ask our community by posting on the mongodb-user group or on Stack Overflow with the mongodb tag.

Comment by RAFIK [ 13/Jun/19 ]

The reason for this is to respond to this query:

db.docs.find({
   $or: [
      {city: 'my-city'},
      {country: 'my-country'}
   ]
}).sort({someCriteria: 1});
 
For me, an index that merge all docs of a city inside a country and all docs of that country (each doc index of a country will be repeated inside each city entry) will be faster then creating single index on each fields: 'city' and 'country' (eliminate time to look for intersections and doing sorts)
I dont know it it'is a good idea
 
 

db.docs.find({})

 

Comment by RAFIK [ 13/Jun/19 ]

Yes, i just found that mongo has that feature and that has "index intersection" that respond to my case very match, (not yeat tested, my case is to get an intersection between fullText search index and multikey index)

Thanks.

 

Comment by Danny Hatcher (Inactive) [ 11/Jun/19 ]

You can use partial indexes which will let you set an equality on specific values in your indexes. Does this fulfill your use case? If not, can you please explain why partial indexes are insufficient?

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