itemsapi / itemsjs

Extremely fast faceted search engine in JavaScript - lightweight, flexible, and simple to use
Apache License 2.0
346 stars 41 forks source link

Faceted search with OR #4

Closed lbineau closed 6 years ago

lbineau commented 6 years ago

Hi @cigolpl, Thank you for your library, it is really nice, I have been looking for a while for a proper faceted search lib without jQuery.

I have a question about the faceted search.

var movies = itemsjs.search({
  per_page: 1,
  sort: 'name_asc',
  filters: {
    tags: ['1980s', '1990s']
  }
})

Will return all movies with 1980s AND 1990s tags. Is it possible to search with OR operator? If I want all movies with 1980s OR 1990s.

Thanks a lot.

cigolpl commented 6 years ago

Hello @lbineau, thanks for feedback!

Yes, it's possible to use OR. You need to set conjunction to false in tags configuration like:

aggregations: {
    tags: {
      title: 'Tags',
      conjunction: false, 
      size: 10
   }
}
lbineau commented 6 years ago

Thanks, it works like a charm!