lucaong / minisearch

Tiny and powerful JavaScript full-text search engine for browser and Node
https://lucaong.github.io/minisearch/
MIT License
4.9k stars 137 forks source link

How to perform AND as well as OR search? #112

Closed Thomas-1985 closed 2 years ago

Thomas-1985 commented 2 years ago

Hi

I just looked at your library and it seems really great. However i searched the docs and didn't find anything regarding how i can configure minisearch to use an AND-based approach (only return elements which match all strings)

Example: This text contains some elements

Searching for "text contains an" should return nothing Searching for "text contains elements" should return the result

I think the behaviour of the library is OR-based, or am i wrong?

Best, Thomas

lucaong commented 2 years ago

Hi @Thomas-1985 , you can perform AND queries by setting the search option combineWith: 'AND', like in the following example:

miniSearch.search('text contains elements', {
  combineWith: 'AND'
})

You can find more information in the docs.

I hope this helps.

lucaong commented 2 years ago

@Thomas-1985 I am closing the issue as the question should be answered, but comment further mentioning me if necessary.