1
votes

I have the following query :

GET product,account/producttype,accounttype/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "bool": {
            "must": [
              {
                "nested": {
                  "query": {
                    "bool": {
                      "should": [
                        {
                          "match": {
                            "keywords.keyword": {
                              "query": "search query"
                            }
                          }
                        },
                        {
                          "term": {
                            "keywords.keyword.keyword": {
                              "value": "search query"
                            }
                          }
                        }
                      ]
                    }
                  },
                  "path": "keywords"
                }
              }
            ],
            "filter": [
              {
                "term": {
                  "_index": {
                    "value": "product"
                  }
                }
              }
            ]
          }
        },
       {
      "bool": {
        "must": [
          {
            "multi_match": {
              "query": "search query",
              "operator": "or",
              "fields": [
                "accountName^1.5",
                "description^0.8"
              ]
            }
          }
        ],
        "filter": [
          {
            "term": {
              "_type": {
                "value": "accounttype"
              }
            }
           }
          ]
        }
       }
      ]
    }
  }
}

When I run the above query I get this exception:

"index": "account", "caused_by": { "type": "illegal_state_exception", "reason": "[nested] failed to find nested object under path [keywords]" }

Inside index account there is no nested object called Keywords.

In the past Indices query was used to solve this issue, but now it's deprecated.

Now as the query above shows: I am using filtering by _index but it still gives me that error.

So, could you please guide me to get rid of that exception and get my query working?

PS:

I am using elasticsearch v5.1.1

1
Hey, this might be a long shot but I got myself into the same trouble. Did you manage to solve this?user1242967

1 Answers

0
votes

You can simply adjust your url to point to the right index: GET product/producttype/_search