# What's wrong with this query, it doesn't work if I only supply one character

**URL:** <https://discuss.elastic.co/t/whats-wrong-with-this-query-it-doesnt-work-if-i-only-supply-one-character/21750>\
**Category:** Elasticsearch\
**Created:** [January 21, 2015, 3:33pm UTC](https://discuss.elastic.co/t/whats-wrong-with-this-query-it-doesnt-work-if-i-only-supply-one-character/21750 "2015-01-21T15:33:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaron\_Lewis](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Aaron\_Lewis](https://discuss.elastic.co/u/Aaron_Lewis)\
**Post date:** [January 21, 2015, 3:33pm UTC](https://discuss.elastic.co/t/whats-wrong-with-this-query-it-doesnt-work-if-i-only-supply-one-character/21750/1 "2015-01-21T15:33:00Z")

</div>

Hi,

I imported a sample data:

{  
"account\_number": 0,  
"balance": 16623,  
"firstname": "Bradshaw",  
"lastname": "Mckenzie",  
"age": 29,  
"gender": "F",  
"address": "244 Columbus Place",  
"employer": "Euron",  
"email": "bradshawmckenzie@euron.com",  
"city": "Hobucken",  
"state": "CO"  
}

Now, this query returns empty result (expected);

curl -XPOST 'localhost:9200/bank/\_search?pretty' -d '  
{  
"query": {  
"bool": {  
"must": [  
{ "match": { "age": "29" } }  
],  
"must\_not": [  
{ "match": { "city": "Hobucken" } }  
]  
}  
}  
}'

But if I replace the "city" part with "H" or "Ho" etc. It doesn't return  
the expected empty result, why is that?

It only works with full word, why is that?

--  
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/a8391d3b-0ed7-4eb6-9984-6f6fb9cf211e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a8391d3b-0ed7-4eb6-9984-6f6fb9cf211e%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:** [January 22, 2015, 9:15am UTC](https://discuss.elastic.co/t/whats-wrong-with-this-query-it-doesnt-work-if-i-only-supply-one-character/21750/2 "2015-01-22T09:15:39Z")

</div>

Because of the analyzers used at index and search time.

May be this could help? [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/partial-matching.html) [http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/partial-matching.html](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/partial-matching.html)

--  
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) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)

> Le 21 janv. 2015 à 16:33, Aaron Lewis [the.warl0ck.1989@gmail.com](mailto:the.warl0ck.1989@gmail.com) a écrit :
> 
> Hi,
> 
> I imported a sample data:
> 
> {  
> "account\_number": 0,  
> "balance": 16623,  
> "firstname": "Bradshaw",  
> "lastname": "Mckenzie",  
> "age": 29,  
> "gender": "F",  
> "address": "244 Columbus Place",  
> "employer": "Euron",  
> "email": "[bradshawmckenzie@euron.com](mailto:bradshawmckenzie@euron.com)",  
> "city": "Hobucken",  
> "state": "CO"  
> }
> 
> Now, this query returns empty result (expected);
> 
> curl -XPOST 'localhost:9200/bank/\_search?pretty' -d '  
> {  
> "query": {  
> "bool": {  
> "must": [  
> { "match": { "age": "29" } }  
> ],  
> "must\_not": [  
> { "match": { "city": "Hobucken" } }  
> ]  
> }  
> }  
> }'
> 
> But if I replace the "city" part with "H" or "Ho" etc. It doesn't return the expected empty result, why is that?
> 
> It only works with full word, why is that?
> 
> --  
> 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) [mailto:elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a8391d3b-0ed7-4eb6-9984-6f6fb9cf211e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a8391d3b-0ed7-4eb6-9984-6f6fb9cf211e%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/a8391d3b-0ed7-4eb6-9984-6f6fb9cf211e%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a8391d3b-0ed7-4eb6-9984-6f6fb9cf211e%40googlegroups.com?utm_medium=email&utm_source=footer).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [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/76B21350-99AC-43D0-B5EE-D232AE40FF53%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/76B21350-99AC-43D0-B5EE-D232AE40FF53%40pilato.fr).  
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, 12:37am UTC](https://discuss.elastic.co/t/whats-wrong-with-this-query-it-doesnt-work-if-i-only-supply-one-character/21750/3 "2017-07-06T00:37:18Z")

</div>

Closed on July 6, 2017, 12:37am UTC


