appbaseio / reactivesearch

Search UI components for React and Vue
https://opensource.appbase.io/reactivesearch
Apache License 2.0
4.89k stars 466 forks source link

CategorySearch - not working - [bool] failed to parse field [must] expected value but got [START_ARRAY] #1649

Closed Debasis-tech closed 2 years ago

Debasis-tech commented 3 years ago

Affected Projects One of React

**Library Version: ( @appbaseio/reactivesearch": "^3.0.0-rc.26") - package.json Inside library - it uses below version.

  1. @appbaseio/reactivesearch@3.16.2
  2. @appbaseio/reactivecore": "9.10.1"
  3. Elastic search version - 7.9

Describe the bug

  1. It is in CategorySearch.
  2. When I am choosing any specific category from the auto suggestion below error I am getting from Elastic search.
  3. FYI (But it works once I choose All category from auto suggestion).
{
    "error": {
        "root_cause": [
            {
                "type": "x_content_parse_exception",
                "reason": "[8:8] [bool] failed to parse field [must]"
            }
        ],
        "type": "x_content_parse_exception",
        "reason": "[8:8] [bool] failed to parse field [must]",
        "caused_by": {
            "type": "x_content_parse_exception",
            "reason": "[8:8] [bool] failed to parse field [must]",
            "caused_by": {
                "type": "illegal_state_exception",
                "reason": "expected value but got [START_ARRAY]"
            }
        }
    },
    "status": 400
}

To Reproduce

  1. Choose any specific category from the auto suggestion ( example - category Book) and run against Elastic search version 7.9 or higher.

Expected behavior It should return the number of matched result from the particular category.

Screenshots response.txt request.txt

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context As per my observation.

  1. when it fires a specific Category search query, it adds one additional square bracket [ (nested) that Elastic search doesn't like.
  2. Once I updated the request query. Removed that extra nested sqare bracket, it started working fine.
  3. Attached is the updated request-working. This category query generation needs to be fixed inside the code. request -fixed-worked.txt
  4. I went through couple of discussion thread about the issue, it appears that the newer version of Elastic search doesn't expect the nested square bracket. Once such discussion thread is below. https://github.com/nextcloud/fulltextsearch_elasticsearch/issues/106

Below nested square bracket causing issue. (snippet from request.json)

{
    "query": {
        "bool": {
            "must": [
                {
                    "bool": {
                        "must": [
                              [ 
                                {
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.