# Query with special characters

**URL:** <https://discuss.elastic.co/t/query-with-special-characters/16818>\
**Category:** Elasticsearch\
**Created:** [April 4, 2014, 9:49am UTC](https://discuss.elastic.co/t/query-with-special-characters/16818 "2014-04-04T09:49:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josep\_Floriach\_Vento](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@Josep\_Floriach\_Vento](https://discuss.elastic.co/u/Josep_Floriach_Vento)\
**Post date:** [April 4, 2014, 9:49am UTC](https://discuss.elastic.co/t/query-with-special-characters/16818/1 "2014-04-04T09:49:54Z")

</div>

Hi guys,

First of all, sorry for possible mistakes with my english (it's not my  
native language)

I'm trying to do a query in a existent index. The field I want to filter is  
Id\_Peticion, which has values like "676E56E8-60A1-7C83-B9C4-1C7B91E35444".  
As you can guess the "-" characters are giving me problems. I'm trying to  
put the backslash to scape the characters, but ES returns me entries that  
not even match with the passed value. In the example above, ES returns the  
following entries:

676E56E8-60A1-7C83-B9C4-1C7B91E35444 \<-- Correct. It should return ONLY this.

C6334797-A70D-DA8C-7C83-27FEAE6FE3EC

84EED3FA-374A-60A1-13AE-222E9F7E11BD

...

And about 20 more entries which not match.

The query I've done:

[http://otzeus.es.gasnatural.com:9200/peticiones-\*/\_search?q=Id\_Peticion:676E56E8-60A1-7C83-B9C4-1C7B91E35444&pretty=true](http://otzeus.es.gasnatural.com:9200/peticiones-*/_search?q=Id_Peticion:676E56E8-60A1-7C83-B9C4-1C7B91E35444&pretty=true)

I'm doing this query via browser. If I quit the backslashes the result is  
exactly the same. What am I doing wrong?

Thanks in advance

--  
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/4cec5b58-413e-49c0-8815-1d6f9989f36f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4cec5b58-413e-49c0-8815-1d6f9989f36f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [April 4, 2014, 7:53pm UTC](https://discuss.elastic.co/t/query-with-special-characters/16818/2 "2014-04-04T19:53:35Z")

</div>

If you already haven't done so, you probably should set this field first to  
not\_analyzed for exact matches to work properly:

{  
"mappings": {  
"doc": {  
"properties": {  
"ld\_Peticion": {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
}  
}  
}

--  
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/14c43a0b-f5ff-4e04-8f7f-b57c8ef1b500%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/14c43a0b-f5ff-4e04-8f7f-b57c8ef1b500%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vladimir\_Khazin](https://avatars.discourse-cdn.com/v4/letter/v/258eb7/32.png) [@Vladimir\_Khazin](https://discuss.elastic.co/u/Vladimir_Khazin)\
**Post date:** [April 4, 2014, 9:35pm UTC](https://discuss.elastic.co/t/query-with-special-characters/16818/3 "2014-04-04T21:35:47Z")

</div>

Id\_Peticion:"676E56E8-60A1-7C83-B9C4-1C7B91E35444&pretty=true[http://www.google.com/url?q=http%3A%2F%2Fotzeus.es.gasnatural.com%3A9200%2Fpeticiones-\*%2F\_search%3Fq%3DId\_Peticion%3A676E56E8%5C-60A1%5C-7C83%5C-B9C4%5C-1C7B91E35444%26pretty%3Dtrue&sa=D&sntz=1&usg=AFQjCNEKnyHwt6\_vqr5jvG-ggt-kKVOOpg](http://www.google.com/url?q=http%3A%2F%2Fotzeus.es.gasnatural.com%3A9200%2Fpeticiones-*%2F_search%3Fq%3DId_Peticion%3A676E56E8%255C-60A1%255C-7C83%255C-B9C4%255C-1C7B91E35444%26pretty%3Dtrue&sa=D&sntz=1&usg=AFQjCNEKnyHwt6_vqr5jvG-ggt-kKVOOpg)

Did not work fro you?

--  
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/8a5fcac9-ff2c-49a0-8fad-285c69994c2a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8a5fcac9-ff2c-49a0-8fad-285c69994c2a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vladimir\_Khazin](https://avatars.discourse-cdn.com/v4/letter/v/258eb7/32.png) [@Vladimir\_Khazin](https://discuss.elastic.co/u/Vladimir_Khazin)\
**Post date:** [April 4, 2014, 9:36pm UTC](https://discuss.elastic.co/t/query-with-special-characters/16818/4 "2014-04-04T21:36:37Z")

</div>

Sorry missed the closing quote to make it a phrase instead of term query:

Id\_Peticion:"676E56E8-60A1-7C83-B9C4-1C7B91E35444"&pretty=true[http://www.google.com/url?q=http%3A%2F%2Fotzeus.es.gasnatural.com%3A9200%2Fpeticiones-\*%2F\_search%3Fq%3DId\_Peticion%3A676E56E8%5C-60A1%5C-7C83%5C-B9C4%5C-1C7B91E35444%26pretty%3Dtrue&sa=D&sntz=1&usg=AFQjCNEKnyHwt6\_vqr5jvG-ggt-kKVOOpg](http://www.google.com/url?q=http%3A%2F%2Fotzeus.es.gasnatural.com%3A9200%2Fpeticiones-*%2F_search%3Fq%3DId_Peticion%3A676E56E8%255C-60A1%255C-7C83%255C-B9C4%255C-1C7B91E35444%26pretty%3Dtrue&sa=D&sntz=1&usg=AFQjCNEKnyHwt6_vqr5jvG-ggt-kKVOOpg)

--  
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/050de560-d312-4e9d-9e69-69a6d5f7b8e3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/050de560-d312-4e9d-9e69-69a6d5f7b8e3%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Josep\_Floriach\_Vento](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@Josep\_Floriach\_Vento](https://discuss.elastic.co/u/Josep_Floriach_Vento)\
**Post date:** [April 8, 2014, 7:30am UTC](https://discuss.elastic.co/t/query-with-special-characters/16818/5 "2014-04-08T07:30:38Z")

</div>

That worked!! I didn't know this field parameter.

Thanks a lot.

On Friday, April 4, 2014 9:53:35 PM UTC+2, Binh Ly wrote:

> If you already haven't done so, you probably should set this field first  
> to not\_analyzed for exact matches to work properly:
> 
> {  
> "mappings": {  
> "doc": {  
> "properties": {  
> "ld\_Peticion": {  
> "type": "string",  
> "index": "not\_analyzed"  
> }  
> }  
> }  
> }  
> }

--  
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/cfbeb4fb-65a3-4305-90f9-cee316838545%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cfbeb4fb-65a3-4305-90f9-cee316838545%40googlegroups.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:37am UTC](https://discuss.elastic.co/t/query-with-special-characters/16818/6 "2017-07-06T01:37:38Z")

</div>


