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

[Feature Request] Support both conjunctions in aggregations #111

Closed chrisdhanaraj closed 2 years ago

chrisdhanaraj commented 2 years ago

Hello! I think this is a feature request, but let me know if this is already possible. Given something like before

{
  genre: Action,
  tags: ['Dark', 'Happy', 'Sad'],
}, 
{
  genre: Adventure
  tags: ['Mysterious']
}

I would love to be able to support both stories of

  1. Show me any movie that is Genre: Action AND Tag:Dark AND Happy

or

  1. Show me any movie that is Genre: ACTION OR Tag: Dark AND Happy

Basically support different kinds of ways to slice and dice the data

This is a great library, feels like one of the only in-browser libraries that supports facets!

cigolpl commented 2 years ago

Hey, thanks for feedback! This feature is already in progress now. Btw don't you mind to say what is your UI use case for this ?

cigolpl commented 2 years ago

This feature is released in version 2.1.16.

You can test it out by providing a new param in search config: filters_query i.e. (tags:novel OR tags:80s) AND category:Western

Please note OR and AND needs to be uppercase. NOT is not yet supported. You can use brackets. The keys like tags, category etc needs to be defined first in aggregations config. If the syntax is not correct it should throw an error. This new param filters_query can be combined with filters param.

Example:

const result = itemsjs.search({
  filters_query: 'tags:novel'
});
chrisdhanaraj commented 2 years ago

Oh amazing 🤩 my use case is actually pretty much what I described - it's an internal tool (Netflix) where we're letting users slice and dice movies by various dimensions; different teams need different connections (I've built a query builder UI to front this library)

cigolpl commented 2 years ago

Hope it is gonna work well for you. Thanks for your use case. It's very helpful for our community to know all possibilities of this engine.

Please spread a word about this library so other people can find it!