Currently 2025, MongoDB community edition is about only 1 full-text index per collection.
The scenario is this:
- Collection C already has full-text for 3 fields: FieldA, FieldB, FieldC
- Need to search for text in FieldA (only 1 field, or the results will be messy)
Problem
- Input is just part of FieldA, not whole value to use regular index
- Input has no starting text trunk in FieldA to utilise index (regex)
- Looping thru' the whole collection is crazy
- Use regex /REGEX/ to
find
method will just be looping without the first trunk of text
Any solutions?
Currently 2025, MongoDB community edition is about only 1 full-text index per collection.
The scenario is this:
- Collection C already has full-text for 3 fields: FieldA, FieldB, FieldC
- Need to search for text in FieldA (only 1 field, or the results will be messy)
Problem
- Input is just part of FieldA, not whole value to use regular index
- Input has no starting text trunk in FieldA to utilise index (regex)
- Looping thru' the whole collection is crazy
- Use regex /REGEX/ to
find
method will just be looping without the first trunk of text
Any solutions?
Share Improve this question edited Mar 22 at 5:52 Dan D asked Mar 21 at 12:15 Dan DDan D 8,6617 gold badges45 silver badges79 bronze badges 01 Answer
Reset to default 0It's current (2025) MongoDB community edition problem, no a complete work-arounds but possibly this way, either
Sacrifice other fields in full-text index for the field to search
Or keep multiple fields in the full-text index, just search them out and fetch a trunk of items from cursor; then loop in the result (of a trunk, not much CPU cost) to find in the wanted field. This won't give complete result set.
The multiple full-text index feature is available on Atlas version (2025), and some said it would come to the on-premise version (Enterprise Advanced) this year.
However, for community edition, a work-around as said above may be needed.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744355025a4570187.html
评论列表(0条)