Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Advanced tags filtering #98

Closed
bobylito opened this issue Jun 6, 2015 · 8 comments
Closed

Advanced tags filtering #98

bobylito opened this issue Jun 6, 2015 · 8 comments
Assignees
Milestone

Comments

@bobylito
Copy link
Contributor

bobylito commented Jun 6, 2015

Algolia API supports AND, OR and NOT filtering. How to provide a good API that easy to read, combine and manipulate?

In Flickr search, the provide a mode that let one query either in AND or OR mode. This does not provide any NOT feature. It is easy though and answer well the easiest cases for which you want to do either or and and filtering.

Maybe having a separate object for handling tag filters could be a solution, even though we ought to provide an object for or groups too... Just throwing some code here :

var tagList = new TagList( "romantic", not( "horror" ) );
var orGroup = new OrGroup( "dinner", "musical" );
tagList.add( orGroup );
helper.setTagList( tagList );
//later...
var l = helper.getTagList();
var excludeTags = l.getExcludedTags();
excludeTags.remove( "horror" );
var orGroups = l.getOrGroups();
orGroups.first().remove( "musical" );
helper.setTagList( tagList );

This API wouldn't be enough or satisfying but that's some food for thinking...

This problem is definitely related to #35 with similar issues and API constraints.

@redox
Copy link
Contributor

redox commented Jun 6, 2015

There is an open feature request in the API backend to support the parsing of boolean expressions -> I would stuck to that and wouldn't implement anything in the API clients.

We would do something like: facetFilters: "(rating:1 OR rating:2) AND facility:wifi"

@bobylito
Copy link
Contributor Author

bobylito commented Jun 7, 2015

The input is the least problematic part here. How do you edit the current tag filters? How do you query those tags?

One thing that could help is a UI or any kind of software sample that uses the advanced combination of and or and negative tag capabilities. The way the user edit this kind of filter might give us an hint about how to do it properly.

@bobylito
Copy link
Contributor Author

bobylito commented Jun 7, 2015

OK so let's make it simple :

  • simple API for the common case, add remove etc with the support of not in the string (you prepend if you want the tag explicitly excluded) and support for two modes : and, or.
  • advanced API that let the programmer enter a string that matches the format proposed by the Algolia API. The uses are much more complex, so chances are that the user/programmer will know what it is doing.

One or the other API should have precedence, and I would say that once on the advanced you should not go back. Therefore I would make the advanced mode have the higher priority.

@bobylito
Copy link
Contributor Author

bobylito commented Jun 7, 2015

//simple mode
helper.setTagMode = "or"; // and by default
helper.addTag( "romantic" )
helper.addTag( "beach" );

// advanced mode
helper.setRawTagFilter( "romantic, ( sea, city ), -mountain" );

@redox
Copy link
Contributor

redox commented Jun 7, 2015

I think that those advanced conditions are only applied programmatically, I would not go for anything else than your "advanced" API which is actually similar than setQueryParameters("tagFilters", ".....").

Moreover, the facet & numeric filters also support those boolean expressions.

@bobylito
Copy link
Contributor Author

bobylito commented Jun 7, 2015

OK agreed!
Don't you think that verifying the string would be a good idea ? Otherwise we just have to make sure that if a user provides the parameters directly using the setQueryParameters we don't override it with the simple API.

@redox
Copy link
Contributor

redox commented Jun 7, 2015

We need to validate/verify that at the API level, otherwise it will be very difficult to maintain.

Yeah, ideally we would be able to "merge" the filters :/

@bobylito
Copy link
Contributor Author

bobylito commented Jun 7, 2015

Hummm I'm interested in a strategy to merge the filters (tbh I have no idea which rules would make sense)

@bobylito bobylito self-assigned this Jun 7, 2015
@bobylito bobylito added this to the 2.1.0 milestone Jun 7, 2015
bobylito pushed a commit that referenced this issue Jun 15, 2015
  * FIX : #29 Avoid callback for outdated queries
  * FIX : #64 Sum up the processing time of all queries
  * FIX : #92 Parameters that can be set in the dashboard shouldn't have defaults
  * FIX : #62 Make sure disctinct is set to false when it's not possible to use distinct in Algolia
  * FEATURE : #91 Support for tags (with support for the raw format #98)
  * FEATURE : #70 Ability to get all refined values : helper.getRefinements( facetname )
  * FEATURE : #51 multiple filters for a single conjunctive facet (tests)
  * FEATURE : Ability to modify any parameter of the state easily (#76 #84 #12)
  * FEATURE : #69 Ability to know if a facet is refined, whatever the value
  * FEATURE : #86 Expose SearchParameters, AlgoliaSearchHelper, SearchResults to users directly in the builds
  * FEATURE : #25 let the user do a clearRefinement with a function as a filter
  * REFACTORING : SearchParameters is immutable (#14)
  * REFACTORING : Ensure SearchParameters is totally frozen (#14)
  * LIB : Update lodash version to 3.9.x
dhayab pushed a commit to algolia/instantsearch that referenced this issue Jul 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants