typesense / typesense-instantsearch-adapter

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

Filter isssues #59

Closed dianos closed 3 years ago

dianos commented 3 years ago

'filters' don't seem to be working for me. numericFilters generate an error. facetFilters do work.

example: 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

May I know what version of Typesense, Instantsearch adapter and Instantsearch you’re using?

dianos commented 3 years ago

Typesense 0.20 Adapter (I tried 3): 1.2.1 , 1.2.2, and 0.3 Instantsearch tried, 4.24, 4.8.3, and 3.7 for 3.7 I used searchparams instead of configure, which generated a similar error.

dianos commented 3 years ago

https://codesandbox.io/s/instantsearchjs-app-forked-wvdes?file=/src/app.js The same error seems to happen without typesense for numericFilters. But the regular filter does work there.

jasonbosco commented 3 years ago

IIRC, Algolia doesn't allow you to mix filters with numericFilters & facetFilters. I think that's what the error message is trying to convey - "filters" being the advanced API and the other two being the managed API.

Separately, typesense-instantsearch-adapter only handles numericFilters & facetFilters and not filters.

So could you try something like this:

configure({ numericFilters: ["price >= 500"], facetFilters: ['brand:lenovo','instock:true'], }),
dianos commented 3 years ago

Algolia is telling people not to use numericfilters directly but to use 'filters' instead.
It's the same error if you use numeric filters alone: [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. I guess there might be some switch/import in algolia's code to turn off filters and use their more primitive cousins?

dianos commented 3 years ago

I'm closing this since the issue is not caused by typesense (other then it not supporting 'filters'). Here is a more lengthy discussion with algoila regarding filters/refinements/uistate: https://github.com/algolia/instantsearch.js/issues/4807