# Returning exact matches with ElasticSearch 'Lite'

**URL:** https://discuss.elastic.co/t/returning-exact-matches-with-elasticsearch-lite/19784
**Category:** Elasticsearch
**Created:** [September 15, 2014, 12:03pm UTC](https://discuss.elastic.co/t/returning-exact-matches-with-elasticsearch-lite/19784 "2014-09-15T12:03:28Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Neil\_Middleton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/neil_middleton/32/1179_2.png) [@Neil\_Middleton](https://discuss.elastic.co/u/Neil_Middleton)
#### Post date: [September 15, 2014, 12:03pm UTC](https://discuss.elastic.co/t/returning-exact-matches-with-elasticsearch-lite/19784/1 "2014-09-15T12:03:28Z")

</div>

I'm trying to use ES's search lite  
[http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/search-lite.html](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/search-lite.html) to  
query a dataset which contains a key foo. An example of this is:

.../\_search?q=+foo:bar-baz

Now, my understanding is is that the addition of + to the foo attribute  
should make this search return only exactly matches where foo is bar-baz.  
However, I'm finding that I'm also getting other results coming back, for  
instance foo-baz or baz-baz etc.

What am I doing wrong here which is causing these other results to be  
returned? How can I resolve this?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [September 15, 2014, 2:12pm UTC](https://discuss.elastic.co/t/returning-exact-matches-with-elasticsearch-lite/19784/2 "2014-09-15T14:12:04Z")

</div>

Use URI escaping (percent encoding). It is perfectly described on the page

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Jörg

On Mon, Sep 15, 2014 at 2:03 PM, Neil Middleton [neil@heroku.com](mailto:neil@heroku.com) wrote:

> I'm trying to use ES's search lite  
> [http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/search-lite.html](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/search-lite.html) to  
> query a dataset which contains a key foo. An example of this is:
> 
> .../\_search?q=+foo:bar-baz
> 
> Now, my understanding is is that the addition of + to the foo attribute  
> should make this search return only exactly matches where foo is bar-baz.  
> However, I'm finding that I'm also getting other results coming back, for  
> instance foo-baz or baz-baz etc.
> 
> What am I doing wrong here which is causing these other results to be  
> returned? How can I resolve this?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoF7%2BF-sQpm2ypm3YWfVgu7H%2BbO6vEAPbw9e4m824Hd8Aw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoF7%2BF-sQpm2ypm3YWfVgu7H%2BbO6vEAPbw9e4m824Hd8Aw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Neil\_Middleton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/neil_middleton/32/1179_2.png) [@Neil\_Middleton](https://discuss.elastic.co/u/Neil_Middleton)
#### Post date: [September 15, 2014, 3:04pm UTC](https://discuss.elastic.co/t/returning-exact-matches-with-elasticsearch-lite/19784/3 "2014-09-15T15:04:57Z")

</div>

Percent encoding the string appears to make no difference. Passing in "+foo:bar-baz” or "%2Bfoo%3Abar-baz” yields exactly the same resultset.

Is this potentially to do with the analysis of the strings in question? For instance - I assume by not analysing the `foo` field the propensity to return ‘similar’ results will be removed as ES won’t have done the analysis on the parts of the word?

For instance: `/_analyze?text=foo-bar` yields something different to say `/_analyze?text=foo-bar&analyzer=whitespace`.

—  
N

On Mon, Sep 15, 2014 at 3:12 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com)  
[joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:

> Use URI escaping (percent encoding). It is perfectly described on the page  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/search-lite.html)  
> Jörg  
> On Mon, Sep 15, 2014 at 2:03 PM, Neil Middleton [neil@heroku.com](mailto:neil@heroku.com) wrote:
> 
> > I'm trying to use ES's search lite  
> > [http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/search-lite.html](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/search-lite.html) to  
> > query a dataset which contains a key foo. An example of this is:
> > 
> > .../\_search?q=+foo:bar-baz
> > 
> > Now, my understanding is is that the addition of + to the foo attribute  
> > should make this search return only exactly matches where foo is bar-baz.  
> > However, I'm finding that I'm also getting other results coming back, for  
> > instance foo-baz or baz-baz etc.
> > 
> > What am I doing wrong here which is causing these other results to be  
> > returned? How can I resolve this?
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/X4wS16I10Ko/unsubscribe](https://groups.google.com/d/topic/elasticsearch/X4wS16I10Ko/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoF7%2BF-sQpm2ypm3YWfVgu7H%2BbO6vEAPbw9e4m824Hd8Aw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoF7%2BF-sQpm2ypm3YWfVgu7H%2BbO6vEAPbw9e4m824Hd8Aw%40mail.gmail.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1410793495416.33166361%40Nodemailer](https://groups.google.com/d/msgid/elasticsearch/1410793495416.33166361%40Nodemailer).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [September 15, 2014, 3:30pm UTC](https://discuss.elastic.co/t/returning-exact-matches-with-elasticsearch-lite/19784/4 "2014-09-15T15:30:45Z")

</div>

Yes, you can select a tokenizer for controlling how to split words.

If you index "bar-baz", you index two words, bar and baz, because standard  
analyzer delimits tokens according to Unicode text segmentation rules in  
[http://unicode.org/reports/tr29/](http://unicode.org/reports/tr29/)

So the easiest method to use standard tokenizer is probably by phrase  
search, and it works like this:

PUT /test/doc/1  
{  
"foo" : "bar"  
}

PUT /test/doc/2  
{  
"foo" : "bar-baz"  
}

GET /test/\_refresh

GET /test/\_search?q=%22bar%2Dbaz%22

Jörg

On Mon, Sep 15, 2014 at 5:04 PM, Neil Middleton [neil@heroku.com](mailto:neil@heroku.com) wrote:

> Percent encoding the string appears to make no difference. Passing in  
> "+foo:bar-baz” or "%2Bfoo%3Abar-baz” yields exactly the same resultset.
> 
> Is this potentially to do with the analysis of the strings in question?  
> For instance - I assume by not analysing the `foo` field the propensity to  
> return ‘similar’ results will be removed as ES won’t have done the analysis  
> on the parts of the word?
> 
> For instance: `/_analyze?text=foo-bar` yields something different to say  
> `/_analyze?text=foo-bar&analyzer=whitespace`.
> 
> —  
> N
> 
> On Mon, Sep 15, 2014 at 3:12 PM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
> [joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:
> 
> > Use URI escaping (percent encoding). It is perfectly described on the  
> > page  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/search-lite.html)
> > 
> > Jörg
> > 
> > On Mon, Sep 15, 2014 at 2:03 PM, Neil Middleton [neil@heroku.com](mailto:neil@heroku.com) wrote:
> > 
> > > I'm trying to use ES's search lite  
> > > [http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/search-lite.html](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/search-lite.html) to  
> > > query a dataset which contains a key foo. An example of this is:
> > > 
> > > .../\_search?q=+foo:bar-baz
> > > 
> > > Now, my understanding is is that the addition of + to the foo attribute  
> > > should make this search return only exactly matches where foo is bar-baz.  
> > > However, I'm finding that I'm also getting other results coming back, for  
> > > instance foo-baz or baz-baz etc.
> > > 
> > > What am I doing wrong here which is causing these other results to be  
> > > returned? How can I resolve this?
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f77af3af-8615-44c2-9d86-f9b6c1692f63%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/X4wS16I10Ko/unsubscribe](https://groups.google.com/d/topic/elasticsearch/X4wS16I10Ko/unsubscribe).  
> > To unsubscribe from this group and all its topics, send an email to  
> > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoF7%2BF-sQpm2ypm3YWfVgu7H%2BbO6vEAPbw9e4m824Hd8Aw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoF7%2BF-sQpm2ypm3YWfVgu7H%2BbO6vEAPbw9e4m824Hd8Aw%40mail.gmail.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoF7%2BF-sQpm2ypm3YWfVgu7H%2BbO6vEAPbw9e4m824Hd8Aw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoF7%2BF-sQpm2ypm3YWfVgu7H%2BbO6vEAPbw9e4m824Hd8Aw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/1410793495416.33166361%40Nodemailer](https://groups.google.com/d/msgid/elasticsearch/1410793495416.33166361%40Nodemailer)  
> [https://groups.google.com/d/msgid/elasticsearch/1410793495416.33166361%40Nodemailer?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/1410793495416.33166361%40Nodemailer?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGnLQ1d5AZQym9n1wWsY\_aC0hfWtZRfouRqHK2jsA%3DdSw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGnLQ1d5AZQym9n1wWsY_aC0hfWtZRfouRqHK2jsA%3DdSw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:02am UTC](https://discuss.elastic.co/t/returning-exact-matches-with-elasticsearch-lite/19784/5 "2017-07-06T01:02:17Z")

</div>


