# Query\_string not returning results for searches less than 3 characters

**URL:** https://discuss.elastic.co/t/query-string-not-returning-results-for-searches-less-than-3-characters/11603
**Category:** Elasticsearch
**Created:** [April 16, 2013, 7:08pm UTC](https://discuss.elastic.co/t/query-string-not-returning-results-for-searches-less-than-3-characters/11603 "2013-04-16T19:08:23Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Darius\_Riggins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/darius_riggins/32/2374_2.png) [@Darius\_Riggins](https://discuss.elastic.co/u/Darius_Riggins)
#### Post date: [April 16, 2013, 7:08pm UTC](https://discuss.elastic.co/t/query-string-not-returning-results-for-searches-less-than-3-characters/11603/1 "2013-04-16T19:08:23Z")

</div>

I'm trying to search for a term such as at&t by only searching for at&, but  
it never works. The field is analyzed and boosted on indexing, and I'm  
wondering if the only way to get that to work is to create  
a separate not\_analyzed field?

{  
"fields": [  
"name",  
"\_id"  
],  
"query": {  
"query\_string": {  
"default\_field": "name",  
"query": "at&"  
}  
}  
"size": 15  
}

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)
#### Post date: [April 16, 2013, 7:11pm UTC](https://discuss.elastic.co/t/query-string-not-returning-results-for-searches-less-than-3-characters/11603/2 "2013-04-16T19:11:59Z")

</div>

ok here is my guess.... you analyzer for the field name tokenizes away the  
'&' and drops stopwords such that 'at' never makes it to the index so you  
get 0 results?

what analyzer are you using for the name field?

simon

On Tuesday, April 16, 2013 9:08:23 PM UTC+2, Darius Riggins wrote:

> I'm trying to search for a term such as at&t by only searching for at&,  
> but it never works. The field is analyzed and boosted on indexing, and I'm  
> wondering if the only way to get that to work is to create  
> a separate not\_analyzed field?
> 
> {  
> "fields": [  
> "name",  
> "\_id"  
> ],  
> "query": {  
> "query\_string": {  
> "default\_field": "name",  
> "query": "at&"  
> }  
> }  
> "size": 15  
> }

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Darius\_Riggins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/darius_riggins/32/2374_2.png) [@Darius\_Riggins](https://discuss.elastic.co/u/Darius_Riggins)
#### Post date: [April 16, 2013, 7:33pm UTC](https://discuss.elastic.co/t/query-string-not-returning-results-for-searches-less-than-3-characters/11603/3 "2013-04-16T19:33:17Z")

</div>

I'm guessing the default one, that field I didn't do anything special  
besides adding a sort field to it. Would it work if I add a new field that  
is not analyzed?

On Tuesday, April 16, 2013 3:11:59 PM UTC-4, simonw wrote:

> ok here is my guess.... you analyzer for the field name tokenizes away the  
> '&' and drops stopwords such that 'at' never makes it to the index so you  
> get 0 results?
> 
> what analyzer are you using for the name field?
> 
> simon
> 
> On Tuesday, April 16, 2013 9:08:23 PM UTC+2, Darius Riggins wrote:
> 
> > I'm trying to search for a term such as at&t by only searching for at&,  
> > but it never works. The field is analyzed and boosted on indexing, and I'm  
> > wondering if the only way to get that to work is to create  
> > a separate not\_analyzed field?
> > 
> > {  
> > "fields": [  
> > "name",  
> > "\_id"  
> > ],  
> > "query": {  
> > "query\_string": {  
> > "default\_field": "name",  
> > "query": "at&"  
> > }  
> > }  
> > "size": 15  
> > }

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)
#### Post date: [April 17, 2013, 8:07pm UTC](https://discuss.elastic.co/t/query-string-not-returning-results-for-searches-less-than-3-characters/11603/4 "2013-04-17T20:07:25Z")

</div>

with the default analyzer you will see the behaviour I explained above. If  
you use some other analyzer that doesn't drop stopwords you should be fine.

simon

On Tuesday, April 16, 2013 9:33:17 PM UTC+2, Darius Riggins wrote:

> I'm guessing the default one, that field I didn't do anything special  
> besides adding a sort field to it. Would it work if I add a new field that  
> is not analyzed?
> 
> On Tuesday, April 16, 2013 3:11:59 PM UTC-4, simonw wrote:
> 
> > ok here is my guess.... you analyzer for the field name tokenizes away  
> > the '&' and drops stopwords such that 'at' never makes it to the index so  
> > you get 0 results?
> > 
> > what analyzer are you using for the name field?
> > 
> > simon
> > 
> > On Tuesday, April 16, 2013 9:08:23 PM UTC+2, Darius Riggins wrote:
> > 
> > > I'm trying to search for a term such as at&t by only searching for at&,  
> > > but it never works. The field is analyzed and boosted on indexing, and I'm  
> > > wondering if the only way to get that to work is to create  
> > > a separate not\_analyzed field?
> > > 
> > > {  
> > > "fields": [  
> > > "name",  
> > > "\_id"  
> > > ],  
> > > "query": {  
> > > "query\_string": {  
> > > "default\_field": "name",  
> > > "query": "at&"  
> > > }  
> > > }  
> > > "size": 15  
> > > }

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Darius\_Riggins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/darius_riggins/32/2374_2.png) [@Darius\_Riggins](https://discuss.elastic.co/u/Darius_Riggins)
#### Post date: [April 17, 2013, 8:43pm UTC](https://discuss.elastic.co/t/query-string-not-returning-results-for-searches-less-than-3-characters/11603/5 "2013-04-17T20:43:00Z")

</div>

Oddly I tried a few other ones, such as simple or lowercase, or keyword,  
really was just throwing things at that point. Making a new psuedo-field  
and setting to not\_analyzed worked fine, not the best option in my case as  
I have to then use a wildcard query to get the behavior I want, but I can  
live with it as I get the results fine now. Thanks for the help.

On Tuesday, April 16, 2013 3:08:23 PM UTC-4, Darius Riggins wrote:

> I'm trying to search for a term such as at&t by only searching for at&,  
> but it never works. The field is analyzed and boosted on indexing, and I'm  
> wondering if the only way to get that to work is to create  
> a separate not\_analyzed field?
> 
> {  
> "fields": [  
> "name",  
> "\_id"  
> ],  
> "query": {  
> "query\_string": {  
> "default\_field": "name",  
> "query": "at&"  
> }  
> }  
> "size": 15  
> }

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:40am UTC](https://discuss.elastic.co/t/query-string-not-returning-results-for-searches-less-than-3-characters/11603/6 "2017-07-06T02:40:43Z")

</div>


