Reactivesearch: inconsistent results after setting and clearing component values

Created on 25 Jun 2019  路  6Comments  路  Source: appbaseio/reactivesearch

Issue Type: bug
Platform: web
Description:
extra terms were added even after the component was cleared

Minimal reproduction of the problem with instructions:
i have a reactiveList which specifies AND/OR/NOT components in the react prop
e.g.

        // andComponents, orComponents, notComponents are all arrays of the components 
        // and they are stored in state
        react={{
          and: andComponents, // contains a CategorySearch component CATSEARCH
          or: orComponents,
          not: notComponents,
        }}

1) say i have 100 results with this setup and CATSEARCH is empty
2) i toggle CATSEARCH to be in the orComponents and i still have 100 results
3) then i typed and entered a query string in CATSEARCH and obtained 101 results since it's in the orComponents
4) i cleared the query string in CATSEARCH but i got back more than 100 results this time which is inconsistent
5) tried to compare the msearch query sent to elasticsearch in step2 and step4 and noticed this {"match_all":{}} difference between the 2 queries

Any idea what's wrong?

Reactivesearch version: 2.18.0
Browser: Chrome 75

All 6 comments

@jwchia1 Can you share a replicable code sandbox (or codepen) which shows the above? It's very hard to comment without that.

@siddharthlatest sure
finally got some time to write this: https://codesandbox.io/s/categorysearch-q7tcq

This sounds very similar to the issue I'm having. I am intermittently seeing an extra query fire when selecting/deselecting an item in a ReactiveList component. This usually (but not always) happens only on the first selection, and the default "match_all" query is launched, followed by the new query. Since the new query returns a smaller result set, it loads briefly before being replaced with the match_all results. Strangely, this only seems to happen when I include either the RangeSlider or RangeInput component in addition to the ReactiveList.

Thanks @jwchia1 for taking the time to create the code sandbox scenario. I am able to see the issue.

@bietkul This is also replicable for the latest RS version: https://codesandbox.io/s/categorysearch-7xgcw (see the instructions in the code sandbox to replicate).

I also inspected the Redux state to better understand the root cause. Here it is:

  1. The initial queryList is only set for components with a value. Components with no value do not apply a query. => This is how it should be.
  2. Once a value is set for it, the component appears to apply a query. => This is how it should be.
  3. When a component's value is cleared (in the above case, for CategorySearch component) though, the component now applies a match_all: {} query. (Ideally, it should not apply a query itself)
    => The reason we don't see this causing an issue is because, by default, the dependency is set using an AND clause, and so the hits are always returned as an intersection of hits from all the components. However, when the dependency is set using an OR clause, the issue appears - as shown with the above code sandbox.

Lmk if this makes sense. It's an important issue IMO.

This sounds very similar to the issue I'm having. I am intermittently seeing an extra query fire when selecting/deselecting an item in a ReactiveList component. This usually (but not always) happens only on the first selection, and the default "match_all" query is launched, followed by the new query. Since the new query returns a smaller result set, it loads briefly before being replaced with the match_all results. Strangely, this only seems to happen when I include either the RangeSlider or RangeInput component in addition to the ReactiveList.

@adadiehl I don't think the two are related. Can you share a codesandbox? And let's keep the discussion for this on #1029.

@siddharthlatest I can easily replicate the issue, we'll fix it in the next version.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jkhaui picture jkhaui  路  3Comments

tiagogm picture tiagogm  路  3Comments

ymzoughi picture ymzoughi  路  4Comments

davidklebanoff picture davidklebanoff  路  4Comments

carlopascual picture carlopascual  路  3Comments