# Could not get stored percolator fields searchable (ES 5.0.0.alpha4)

**URL:** <https://discuss.elastic.co/t/could-not-get-stored-percolator-fields-searchable-es-5-0-0-alpha4/55175>\
**Category:** Elasticsearch\
**Created:** [July 11, 2016, 10:05am UTC](https://discuss.elastic.co/t/could-not-get-stored-percolator-fields-searchable-es-5-0-0-alpha4/55175 "2016-07-11T10:05:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mumpi](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mumpi](https://discuss.elastic.co/u/mumpi)\
**Post date:** [July 11, 2016, 10:05am UTC](https://discuss.elastic.co/t/could-not-get-stored-percolator-fields-searchable-es-5-0-0-alpha4/55175/1 "2016-07-11T10:05:30Z")

</div>

Under ES 2 i have an application for maintaining stored percolator documents. The percolator query-field and subfields are indexed to \_all. That's fine because percolator documents to edit should be found by metadata as well as used query-terms.

In ES 5.0.0. alpha4 I could not get the terms of the percolator query searchable. The field data type "percolator" does not index to \_all and does not accept any other parameters like "copy\_to".

I tried also to index my percolator query field as "object" and then "copy\_to" a field with type "percolator": Has been rejected.

Ideas to get that working again are appreciated very much. Thanks.

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [July 11, 2016, 3:26pm UTC](https://discuss.elastic.co/t/could-not-get-stored-percolator-fields-searchable-es-5-0-0-alpha4/55175/2 "2016-07-11T15:26:45Z")

</div>

The answer is "maybe", depending on what you need.

It's true that the new percolator data type doesn't index into the `_all` field, and doesn't support the `copy_to` parameter either. It does, however, internally extract some terms to use for faster percolator runtime. That extracted field may contain what you need.

If your percolator field is called `"query"`, you can search the extracted terms via the `"query.extracted_terms"` multi-field.

The field will contain some of the extracted terms, depending on context (e.g. if the query is a bool, it will contain the should clauses. If there is a must clause, it will contain the must clause with the longest terms, etc). So it's not all the terms in the query, and it doesn't contain the actual query names/types either.

If that field doesn't satisfy your needs, currently the only option is to manually duplicate the query contents into a secondary field in your application (e.g. before registering the query).

Perhaps open a ticket requesting support for `copy_to`? That seems like it would be a sensible feature, if there isn't a technical blocker to keep it from happening.

---

<div class="post-metadata">

**Author:** ![mumpi](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mumpi](https://discuss.elastic.co/u/mumpi)\
**Post date:** [July 12, 2016, 7:42am UTC](https://discuss.elastic.co/t/could-not-get-stored-percolator-fields-searchable-es-5-0-0-alpha4/55175/3 "2016-07-12T07:42:03Z")

</div>

Thank you. The "query.extracted\_terms" did not help in my case; it showed for all my tries 0 hits; May be this is because I use "query\_string" queries. But that proved to be an easy way to come from a "significant\_terms" aggregation to a percolator.

I try to open a feature request.

---

<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:** [July 12, 2016, 9:08am UTC](https://discuss.elastic.co/t/could-not-get-stored-percolator-fields-searchable-es-5-0-0-alpha4/55175/4 "2016-07-12T09:08:04Z")

</div>

@mumpi `query_string` queries on their own can be extracted, but in the case that ranges, fuzzy or wildcard operators are used then the percolator is unable to extract terms. Is that the case for all your percolator queries? Would be good to know why no terms are extracted. If terms are extracted the `percolate` query can perform much better.

Regardless of this I think adding `copy_to` support to the `percolator` field type makes sense.

---

<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:** [July 12, 2016, 9:39am UTC](https://discuss.elastic.co/t/could-not-get-stored-percolator-fields-searchable-es-5-0-0-alpha4/55175/5 "2016-07-12T09:39:30Z")

</div>

I forgot to mention that the `extracted_terms` does use a special format.  
Assuming this query `match: { foo: bar }`, the query.extracted\_terms field holds: foo\0bar

So I think it isn't usable at all for this use case... apologies for the confusion.

---

<div class="post-metadata">

**Author:** ![mumpi](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mumpi](https://discuss.elastic.co/u/mumpi)\
**Post date:** [July 12, 2016, 9:51am UTC](https://discuss.elastic.co/t/could-not-get-stored-percolator-fields-searchable-es-5-0-0-alpha4/55175/6 "2016-07-12T09:51:00Z")

</div>

See below one of my percolators. How can I make visible extracted terms?

{  
"\_index": "smdperc\_de",  
"\_type": "percolator",  
"\_id": "category:Politik|Staatsfinanzen, Steuern|Staatsfinanzen\_Steuern\_dt",  
"\_score": 0.006514681,  
"\_source": {  
"titel": "Politik | Staatsfinanzen, Steuern | Staatsfinanzen\_Steuern\_dt",  
"taxonomy": "category",  
"quelle": "recommind",  
"bearbeitungsPrio": "1",  
"bearbeitungsStatus": "imported",  
"aktiv": false,  
"la": "de",  
"query": {  
"query\_string": {  
"default\_field": "mainqueryRoot",  
"default\_operator": "OR",  
"query": "kanton steuer finanzausgleich bund finanzminister franken franke frank finanzdirektor steuern steuereinnahme steuersenkung steuersatz besteuern besteuerung steuerpflichtig ausgeben steuerzahler million besteuert steuerpflichtige steuerlich kantonal einkommen steuerverwaltung steuergesetz voranschlag finanzpolitisch budget steuerwettbewerb steuerfuss fdp milliarde steuererhoehung einnahme nfa kuerzung sp parlament entlastung svp steuerbelastung jaehrlich steuerausfall erhoehung defizit mehrwertsteuer beitrag gemeinde geld steuersystem regierung betragen subvention finanzierung betrag ausgabe bundesrat senken entlasten fiskus mehreinnahme prozent kosen bundessteuer budgetieren regierungsrat finanziell budgetiert einkommenssteuer cvp einnehmen vorschlag kosten merzen zahlen einsparung vorlage finanzplan finanzieren sparmassnahme zusaetzlich investition sparen 2007 senke finanzpolitik steuerreform 2008 erhoehen haushalt degressiv bundeshaushalt rat zahl rechnung staatshaushalt steuergesetzrevision reform finanz",  
"minimum\_should\_match": "10%"  
}  
}  
}

---

<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:** [July 13, 2016, 12:32pm UTC](https://discuss.elastic.co/t/could-not-get-stored-percolator-fields-searchable-es-5-0-0-alpha4/55175/7 "2016-07-13T12:32:28Z")

</div>

The `extracted_terms` field contains all the query terms from the `query_string` query, but specially formatted so it is know to field each query term belongs

So for example the query term `fdp` can be queried via a term query:

```auto
{
  "term" : {
      "query.mainqueryRoot" : "mainqueryRoot\0fdp"
  }
}

```

However I do doubt if this actually helps you with the setup you had working in ES 2.

So I think the best thing you can do is to tag your documents with terms from the query in a special field. This way you're in full control over how your documents contain percolator queries are retrievable.

---

<div class="post-metadata">

**Author:** ![mumpi](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mumpi](https://discuss.elastic.co/u/mumpi)\
**Post date:** [July 13, 2016, 1:45pm UTC](https://discuss.elastic.co/t/could-not-get-stored-percolator-fields-searchable-es-5-0-0-alpha4/55175/8 "2016-07-13T13:45:40Z")

</div>

I give up, store the query in an ordinary metadata field and change my editor to copy the query also to the percolator field.

Thank you for your effort.

---

<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:** [July 5, 2017, 10:36pm UTC](https://discuss.elastic.co/t/could-not-get-stored-percolator-fields-searchable-es-5-0-0-alpha4/55175/9 "2017-07-05T22:36:04Z")

</div>


