itemsapi / itemsjs

Extremely fast faceted search engine in JavaScript - lightweight, flexible, and simple to use

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Support both conjunctions in aggregations

chrisdhanaraj opened this issue · comments

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!

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 ?

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'
});

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)

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!