Cannot match percolator on multiple fields (ES 5.5)

I register 2 queries in the percolator:

{
     "query": {
          "query_string": {
              "query": "en",
              "fields": ["language"]
         }
     }
}

and

 {
     "query": {
        "query_string": {
            "query": "foo",
            "fields": ["body.*"]
        }
     }
}

where "body" contains 2 inner fields "en" and "fr".
however when i try to match below document to the registered percolator queries, only first query is returned, second one not.

{
    "query" : {
       "percolate" : {
            "field" : "query",
            "document_type" : "doctype",
            "document" : {
                "body" : {"en" : "foo"},
                "language" : "en",
            }
        }
    }
}

What could be the reason? (i tried index this document and query with both queries, both of them return the doc.)

Thansk for the help,
Toan.

The likely reason the second query doesn't match is that at the time the percolator query is indexed the body.en field doesn't exist yet. Resulting in this percolator query to not match with any document.

Can you try specifying the body.en field in your mapping and then reindex this query? (maybe the field already exists and then you should try to just reindex the query) I expect that then the second query will match with the percolate query.

Hi Martijn,

Thanks for the reply. You are right, the issue is i used dynamic template and "body" field is an object, so at the time the percolator query "body.*" is indexed, the field "body.en" doesn’t exist yet.

To fix the issue I indexed a fake document which contains all possible languages in the body, e.g body.en, body.fr, body.de etc.... before indexing percolator query "body.*" then delete this document afterward.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.