# QueryString query on not\_analyzed field

**URL:** <https://discuss.elastic.co/t/querystring-query-on-not-analyzed-field/18319>\
**Category:** Elasticsearch\
**Created:** [June 25, 2014, 8:11am UTC](https://discuss.elastic.co/t/querystring-query-on-not-analyzed-field/18319 "2014-06-25T08:11:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaron\_Martin\_Bermejo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron_martin_bermejo/32/1435_2.png) [@Aaron\_Martin\_Bermejo](https://discuss.elastic.co/u/Aaron_Martin_Bermejo)\
**Post date:** [June 25, 2014, 8:11am UTC](https://discuss.elastic.co/t/querystring-query-on-not-analyzed-field/18319/1 "2014-06-25T08:11:43Z")

</div>

Hello,

My problem is that I have a not\_analyzed field and I'm doing a query\_string  
query over it searching the first word of the field. That query doesn't  
return anything. It can be reproduced doing the next steps:

1. Create an index with the next mapping: [http://pastebin.com/Bz4qxEDS](http://pastebin.com/Bz4qxEDS)

2. Index an object at the index "test1" with the next json:  
{"TextProperty": "This-is-a-test-property"}

3. Make the next query: {"query": {"bool": {"must": [{"query\_string":  
{"default\_field": "TextProperty","query": "_This_"}}]}}}

The query does not return anything. But if I change the query for "_his_"  
it doues return the object previously indexed.

I'm doing this query because I want to make a query that returns every  
result that "contains" the value I'm searching. I don't know if it's normal  
that over not\_indexed fields the query string queries don't work as  
expected or maybe I should make another kind of query or anything else. The  
point is that that query does not work.

I'm open to any solution.

--  
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/62651c7b-9f07-4f1e-b0e6-4326d83b3d7f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/62651c7b-9f07-4f1e-b0e6-4326d83b3d7f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Aaron\_Martin\_Bermejo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron_martin_bermejo/32/1435_2.png) [@Aaron\_Martin\_Bermejo](https://discuss.elastic.co/u/Aaron_Martin_Bermejo)\
**Post date:** [July 4, 2014, 8:22am UTC](https://discuss.elastic.co/t/querystring-query-on-not-analyzed-field/18319/2 "2014-07-04T08:22:49Z")

</div>

Someone can help me please?

El miércoles, 25 de junio de 2014 10:11:43 UTC+2, Aarón Martín Bermejo  
escribió:

> Hello,
> 
> My problem is that I have a not\_analyzed field and I'm doing a  
> query\_string query over it searching the first word of the field. That  
> query doesn't return anything. It can be reproduced doing the next steps:
> 
> 1. Create an index with the next mapping: [Not analyzed mapping - Pastebin.com](http://pastebin.com/Bz4qxEDS)
> 
> 2. Index an object at the index "test1" with the next json:  
> {"TextProperty": "This-is-a-test-property"}
> 
> 3. Make the next query: {"query": {"bool": {"must": [{"query\_string":  
> {"default\_field": "TextProperty","query": "_This_"}}]}}}
> 
> The query does not return anything. But if I change the query for "_his_"  
> it doues return the object previously indexed.
> 
> I'm doing this query because I want to make a query that returns every  
> result that "contains" the value I'm searching. I don't know if it's normal  
> that over not\_indexed fields the query string queries don't work as  
> expected or maybe I should make another kind of query or anything else. The  
> point is that that query does not work.
> 
> I'm open to any solution.

--  
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/fce70d28-69e4-47a4-9a44-97dc9202097d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fce70d28-69e4-47a4-9a44-97dc9202097d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 4, 2014, 8:53am UTC](https://discuss.elastic.co/t/querystring-query-on-not-analyzed-field/18319/3 "2014-07-04T08:53:13Z")

</div>

This one is working:

GET test/test1/\_search  
{  
"query": {  
"wildcard": {  
"TextProperty": "_This_"  
}  
}  
}

But note that you should not do that.

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html)

Note this query can be slow, as it needs to iterate over many terms. In order to prevent extremely slow wildcard queries, a wildcard term should not start with one of the wildcards \* or ?.

You'd better use a ngram token filter.

My 2 cents

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 4 juillet 2014 à 10:22:53, Aarón Martín Bermejo (aamarber@karira.es) a écrit:

Someone can help me please?

El miércoles, 25 de junio de 2014 10:11:43 UTC+2, Aarón Martín Bermejo escribió:  
Hello,

My problem is that I have a not\_analyzed field and I'm doing a query\_string query over it searching the first word of the field. That query doesn't return anything. It can be reproduced doing the next steps:

1. Create an index with the next mapping: [http://pastebin.com/Bz4qxEDS](http://pastebin.com/Bz4qxEDS)

2. Index an object at the index "test1" with the next json: {"TextProperty": "This-is-a-test-property"}

3. Make the next query: {"query": {"bool": {"must": [{"query\_string": {"default\_field": "TextProperty","query": "_This_"}}]}}}

The query does not return anything. But if I change the query for "_his_" it doues return the object previously indexed.

I'm doing this query because I want to make a query that returns every result that "contains" the value I'm searching. I don't know if it's normal that over not\_indexed fields the query string queries don't work as expected or maybe I should make another kind of query or anything else. The point is that that query does not work.

## I'm open to any solution.

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/fce70d28-69e4-47a4-9a44-97dc9202097d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fce70d28-69e4-47a4-9a44-97dc9202097d%40googlegroups.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/etPan.53b66b79.41b71efb.2fae%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.53b66b79.41b71efb.2fae%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Aaron\_Martin\_Bermejo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron_martin_bermejo/32/1435_2.png) [@Aaron\_Martin\_Bermejo](https://discuss.elastic.co/u/Aaron_Martin_Bermejo)\
**Post date:** [July 4, 2014, 11:08am UTC](https://discuss.elastic.co/t/querystring-query-on-not-analyzed-field/18319/4 "2014-07-04T11:08:59Z")

</div>

Thanks a lot David! That one works and I will investigate on the ngram  
token filter. Best regards!

El viernes, 4 de julio de 2014 10:53:25 UTC+2, David Pilato escribió:

> This one is working:
> 
> GET test/test1/\_search  
> {  
> "query": {  
> "wildcard": {  
> "TextProperty": "_This_"  
> }  
> }  
> }
> 
> But note that you should not do that.
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html)
> 
> Note this query can be slow, as it needs to iterate over many terms. In  
> order to prevent extremely slow wildcard queries, a wildcard term should  
> not start with one of the wildcards \* or ?.
> 
> You'd better use a ngram token filter.
> 
> My 2 cents
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr  
> [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 4 juillet 2014 à 10:22:53, Aarón Martín Bermejo (aama...@karira.es  
> \<javascript:\>) a écrit:
> 
> Someone can help me please?
> 
> El miércoles, 25 de junio de 2014 10:11:43 UTC+2, Aarón Martín Bermejo  
> escribió:
> 
> > Hello,
> > 
> > My problem is that I have a not\_analyzed field and I'm doing a  
> > query\_string query over it searching the first word of the field. That  
> > query doesn't return anything. It can be reproduced doing the next steps:
> > 
> > 1. Create an index with the next mapping: [Not analyzed mapping - Pastebin.com](http://pastebin.com/Bz4qxEDS)
> > 
> > 2. Index an object at the index "test1" with the next json:  
> > {"TextProperty": "This-is-a-test-property"}
> > 
> > 3. Make the next query: {"query": {"bool": {"must": [{"query\_string":  
> > {"default\_field": "TextProperty","query": "_This_"}}]}}}
> > 
> > The query does not return anything. But if I change the query for "_his_"  
> > it doues return the object previously indexed.
> > 
> > I'm doing this query because I want to make a query that returns every  
> > result that "contains" the value I'm searching. I don't know if it's normal  
> > that over not\_indexed fields the query string queries don't work as  
> > expected or maybe I should make another kind of query or anything else. The  
> > point is that that query does not work.
> > 
> > I'm open to any solution.
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/fce70d28-69e4-47a4-9a44-97dc9202097d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fce70d28-69e4-47a4-9a44-97dc9202097d%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/fce70d28-69e4-47a4-9a44-97dc9202097d%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/fce70d28-69e4-47a4-9a44-97dc9202097d%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/27b09516-9825-4a30-948d-93b61c01a91e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/27b09516-9825-4a30-948d-93b61c01a91e%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:17am UTC](https://discuss.elastic.co/t/querystring-query-on-not-analyzed-field/18319/5 "2017-07-06T01:17:53Z")

</div>


