# Reverse pattern search analyser

**URL:** <https://discuss.elastic.co/t/reverse-pattern-search-analyser/62975>\
**Category:** Elasticsearch\
**Created:** [October 13, 2016, 5:54pm UTC](https://discuss.elastic.co/t/reverse-pattern-search-analyser/62975 "2016-10-13T17:54:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dj\_Gilcrease](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@Dj\_Gilcrease](https://discuss.elastic.co/u/Dj_Gilcrease)\
**Post date:** [October 13, 2016, 5:54pm UTC](https://discuss.elastic.co/t/reverse-pattern-search-analyser/62975/1 "2016-10-13T17:54:46Z")

</div>

I am wondering if it is possible to create a "reverse" pattern search/query analyser where the pattern is stored in the field and the string to match against is the query

As an example

doc:  
my\_field\_re: bla-[a-z0-9]+

query:  
my\_field\_re: boo-test

nothing returned

query:  
my\_field\_re: bla-test

doc returned

query:  
my\_field\_re: bla-test-more

nothing returned

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [October 13, 2016, 6:07pm UTC](https://discuss.elastic.co/t/reverse-pattern-search-analyser/62975/2 "2016-10-13T18:07:22Z")

</div>

Have a look at the `groups` parameter [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-pattern-tokenizer.html). I think that is what you want.

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [October 13, 2016, 6:11pm UTC](https://discuss.elastic.co/t/reverse-pattern-search-analyser/62975/3 "2016-10-13T18:11:21Z")

</div>

Hi,

this is probably possible with [percolator api](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-percolate.html). You register your pattern as percolator queries (potentially with some metadata, then you percolate your docs containing the string to match against it. I think the only step missing is the "doc return" part, in the standard way you get back the Id of the percolate query. You probably need a second lookup fo the doc content by Id.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [October 13, 2016, 6:22pm UTC](https://discuss.elastic.co/t/reverse-pattern-search-analyser/62975/4 "2016-10-13T18:22:37Z")

</div>

Whoops! Sorry, I thought you wanted a different thing because I didn't read closely. Sorry!

---

<div class="post-metadata">

**Author:** ![Dj\_Gilcrease](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@Dj\_Gilcrease](https://discuss.elastic.co/u/Dj_Gilcrease)\
**Post date:** [October 14, 2016, 9:32pm UTC](https://discuss.elastic.co/t/reverse-pattern-search-analyser/62975/5 "2016-10-14T21:32:32Z")

</div>

Thank you, the percolator api looks very promising.

---

<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:12pm UTC](https://discuss.elastic.co/t/reverse-pattern-search-analyser/62975/6 "2017-07-05T22:12:07Z")

</div>


