nextapps-de / flexsearch

Next-Generation full text search library for Browser and Node.js
Apache License 2.0
12.53k stars 491 forks source link

Proximity Search #256

Closed 3CE8D2BAC65BDD6AA9 closed 2 years ago

3CE8D2BAC65BDD6AA9 commented 3 years ago

Does Flexsearch have proximity search.

A proximity search looks for terms that are within a specific distance from one another.

To perform a proximity search, add the tilde character ~ and a numeric value to the end of a search phrase. For example, to search for a "apache" and "jakarta" within 10 words of each other in a document, use the search:

"jakarta apache"~10

The distance referred to here is the number of term movements needed to match the specified phrase. In the example above, if "apache" and "jakarta" were 10 spaces apart in a field, but "apache" appeared before "jakarta", more than 10 term movements would be required to move the terms together and position "apache" to the right of "jakarta" with a space in between.

akvadrako commented 2 years ago

@3CE8D2BAC65BDD6AA9 did you ever find a JS search library which suits your needs? I'm also looking for phrase and proximity searches.

ts-thomas commented 2 years ago

To limit by distance you should use the "contextual index" feature by settings depth to the maximum distance you need to support (lower is better): https://github.com/nextapps-de/flexsearch#enable-contextual-scoring