# Cannot match percolator on multiple fields (ES 5.5)

**URL:** <https://discuss.elastic.co/t/cannot-match-percolator-on-multiple-fields-es-5-5/98731>\
**Category:** Elasticsearch\
**Created:** [August 29, 2017, 4:47pm UTC](https://discuss.elastic.co/t/cannot-match-percolator-on-multiple-fields-es-5-5/98731 "2017-08-29T16:47:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![toanluu](https://avatars.discourse-cdn.com/v4/letter/t/ad7895/32.png) [@toanluu](https://discuss.elastic.co/u/toanluu)\
**Post date:** [August 29, 2017, 4:47pm UTC](https://discuss.elastic.co/t/cannot-match-percolator-on-multiple-fields-es-5-5/98731/1 "2017-08-29T16:47:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [August 30, 2017, 9:04am UTC](https://discuss.elastic.co/t/cannot-match-percolator-on-multiple-fields-es-5-5/98731/2 "2017-08-30T09:04:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![toanluu](https://avatars.discourse-cdn.com/v4/letter/t/ad7895/32.png) [@toanluu](https://discuss.elastic.co/u/toanluu)\
**Post date:** [September 4, 2017, 8:23am UTC](https://discuss.elastic.co/t/cannot-match-percolator-on-multiple-fields-es-5-5/98731/3 "2017-09-04T08:23:06Z")

</div>

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](http://body.fr), [body.de](http://body.de) etc.... before indexing percolator query "body.\*" then delete this document afterward.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 2, 2017, 8:37am UTC](https://discuss.elastic.co/t/cannot-match-percolator-on-multiple-fields-es-5-5/98731/4 "2017-10-02T08:37:00Z")

</div>

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