# Prefix query exact match

**URL:** <https://discuss.elastic.co/t/prefix-query-exact-match/75836>\
**Category:** Elasticsearch\
**Created:** [February 21, 2017, 8:37am UTC](https://discuss.elastic.co/t/prefix-query-exact-match/75836 "2017-02-21T08:37:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emrah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emrah/32/17657_2.png) [@Emrah](https://discuss.elastic.co/u/Emrah)\
**Post date:** [February 21, 2017, 8:37am UTC](https://discuss.elastic.co/t/prefix-query-exact-match/75836/1 "2017-02-21T08:37:39Z")

</div>

Hi,

i have text fields like above  
elastic|b|c  
elastic,search|b|c  
elastic,search,prefix|b|c

I want to query on this string with prefix. And the query is

aggs":{"field":{"filter":{"match":{"field":{"type":"prefix","query":"elastic|"}}}  
,"aggs":{"field":{"terms":{"field":"textField","size":255}}}}}},"

and this query return all texts below in the example.  
Do i need extra analyzer or token filter on texts?  
How can i exact match search with prefix on elastic ?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 21, 2017, 9:24am UTC](https://discuss.elastic.co/t/prefix-query-exact-match/75836/2 "2017-02-21T09:24:18Z")

</div>

Are the fields you posted exactly like that, ie a keyword?

---

<div class="post-metadata">

**Author:** ![Emrah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emrah/32/17657_2.png) [@Emrah](https://discuss.elastic.co/u/Emrah)\
**Post date:** [February 21, 2017, 9:36am UTC](https://discuss.elastic.co/t/prefix-query-exact-match/75836/3 "2017-02-21T09:36:02Z")

</div>

Fields actually analyzed list of a string that has a analyzer with "+" sign "elastic|b|c+elastic,search|b|c+elastic,search,prefix|b|c"

Indeed, now i got it that prefix query does not support an analyzed string, but i need to analyze the text and query on it like "Contains" or "IndexOf" methods. Actually i'm trying to get the text which is contains "elastic|" . And i need any suggestion faster than regex query by the way

---

<div class="post-metadata">

**Author:** ![Emrah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emrah/32/17657_2.png) [@Emrah](https://discuss.elastic.co/u/Emrah)\
**Post date:** [February 21, 2017, 9:44am UTC](https://discuss.elastic.co/t/prefix-query-exact-match/75836/4 "2017-02-21T09:44:02Z")

</div>

I have two options actually :

1. A Nested list string with no analyzer and prefix search on it ;  
{  
elastic|b|c  
elastic,search|b|c  
elastic,search,prefix|b|c  
}
2. A regex query (no wildcard included) on analyzed string

Which is the best for my case ?

---

<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:** [March 21, 2017, 9:44am UTC](https://discuss.elastic.co/t/prefix-query-exact-match/75836/5 "2017-03-21T09:44:15Z")

</div>

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