MongoFramework icon indicating copy to clipboard operation
MongoFramework copied to clipboard

Add n-gram/partial helpers for Text indexes

Open Turnerj opened this issue 4 years ago • 0 comments

Currently MongoDB doesn't support partial queries on text indexes. As a way to alleviate it, I saw a comment on MongoDB's Jira about a way to work around it by using an additional text field to store n-grams.

Through a combination of entity mutators and the indexing system, it would be possible to do such functionality.

On insert and update, if a mutator looked at all the fields that have text indexes, generated n-grams from those fields and stored it into another property. Have this new property indexed as part of the same text index as the other properties.

It would be able to look up the other text indexes through the Entity Mapping system. The end result is a normal text query automatically looking at the additional text field with all the partial words known to be in the content.

Considerations:

  • The actual configuration for n-grams (how big, how many, what words to never consider)
  • Making sure the n-gram results are store uniquely

Turnerj avatar Jul 09 '19 06:07 Turnerj