typesense / typesense-instantsearch-adapter

A JS adapter library to build rich search interfaces with Typesense and InstantSearch.js
MIT License
393 stars 63 forks source link

Support for `<Configure filters={...} />` #40

Closed fedden closed 3 years ago

fedden commented 3 years ago

Description

Hi there, I was wondering if the typesense adapter supports filters such as these. I can't see it in the documentation so I'm not too hopeful but it appears you support facetFilters according to issue #11 and not sure what else may be supported.

FacetFilters don't seem to support numeric boolean logic which is what I need to do for my usecase (e.g filter the data points by some numeric value, e.g cats < 12), so if there is another approach that I'm not seeing I'd be deeply appreciative of a point in the right direction.

Steps to reproduce

  1. Define some valid filters rule, e.g:

    bedrooms: 4 TO 6 AND list_price: 60000 TO 70000
  2. Pass to react Configure web component:

    <Configure filters="bedrooms: 4 TO 6 AND list_price: 60000 TO 70000"/>

Expected Behavior

I was hoping to see the filter rule applied to my data.

Actual Behavior

The filter rule is not applied to the data returned by the query.

Metadata

Typsense Version: 0.19

OS: Ubuntu 16.04

fedden commented 3 years ago

Another thing I have tried with <Configure ...> is to use the numericFilters prop over the newer filters prop. So for example my filters rule was:

bedrooms: 4 TO 6 AND list_price: 60000 TO 70000

If I then created an array of numeric filter rules using the different syntax, e.g:

<Configure numericFilters={[ "bedrooms >= 4", "bedrooms <= 6", "list_price >= 60000", "list_price <= 70000" ]} />

I'm still struggling to see the data filtered as I would expect it to be. I'm sure I must be missing something obvious to someone more in-tune with this codebase - so if anyone knows how to filter numerical data I'll appreciate your input here!

Thanks 🙂

fedden commented 3 years ago

Oh wait... I'm sorry. It's super late here and I had a typo in my code. I can confirm that the numericFilters approach is working so please ignore this issue. Apologies for the noise but hope this may help some future reader!

dianos commented 3 years ago

Filters don't seem to be working for me at all. While numericFilters generate an error. facetFilters do work.

configure({ filters: 'price >= 200', numericFilters: ["price >= 500"], facetFilters: ['brand:lenovo','instock:true'], }), error generated by numericFilters: index.js:349 Uncaught Error: [Numeric filters] Can't switch from the advanced to the managed API. It is probably an error, if this is really what you want, you have to first clear the numeric filters. at Function.SearchParameters.validate (index.js:349) at SearchParameters.setQueryParameters (index.js:1362) at Object.getWidgetSearchParameters (connectNumericMenu.js:161) at index.js:83 at Array.reduce () at getLocalWidgetsSearchParameters (index.js:78) at Object.init (index.js:297) at InstantSearch.start (InstantSearch.js:431) at Object.parcelRequire.src/app.js.jquery (app.js:259)

jasonbosco commented 3 years ago

Let's continue the conversation here.