# Matching arrays of single character strings

**URL:** <https://discuss.elastic.co/t/matching-arrays-of-single-character-strings/9613>\
**Category:** Elasticsearch\
**Created:** [November 7, 2012, 11:42pm UTC](https://discuss.elastic.co/t/matching-arrays-of-single-character-strings/9613 "2012-11-07T23:42:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Edgin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tony_edgin/32/2643_2.png) [@Tony\_Edgin](https://discuss.elastic.co/u/Tony_Edgin)\
**Post date:** [November 7, 2012, 11:42pm UTC](https://discuss.elastic.co/t/matching-arrays-of-single-character-strings/9613/1 "2012-11-07T23:42:19Z")

</div>

Hi everyone.

Here's an experiment I performed and am surprised by the result. Starting  
with a clean Elastic Search install, I insert a document that as a field  
that is an array of single character strings.

$ curl -XPUT [http://localhost:9200/index/type/id](http://localhost:9200/index/type/id) -d '{ "array" : ["a", "b"]  
}'

I now perform a term search for the document using one of the elements in  
the array.

$ curl -XGET "[http://localhost:9200/\_search?q=array:a&pretty](http://localhost:9200/_search?q=array:a&pretty)"  
{  
"took" : 1,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 0,  
"max\_score" : null,  
"hits" : []  
}  
}

It doesn't find the document. If I repeat the about experiment with two  
character strings, the document is found. Is there a limit to how short a  
string can be matched in an array?

Cheers,  
Tony

--

---

<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:** [November 8, 2012, 2:36am UTC](https://discuss.elastic.co/t/matching-arrays-of-single-character-strings/9613/2 "2012-11-08T02:36:13Z")

</div>

Hi Tony,

You are using defaults.  
That means your field is using a standard analyzer (an english language analyzer).

"a" is a common word in english. So it will not be indexed by ES (see stopwords).

You have to change your mapping and set your field analyzer to keyword (for example).

Have a look at analyze API. It will help you to understand how ES will index your Strings.

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 8 nov. 2012 à 00:42, Tony Edgin [tedgin.iplant@gmail.com](mailto:tedgin.iplant@gmail.com) a écrit :

> Hi everyone.
> 
> Here's an experiment I performed and am surprised by the result. Starting with a clean Elastic Search install, I insert a document that as a field that is an array of single character strings.
> 
> $ curl -XPUT [http://localhost:9200/index/type/id](http://localhost:9200/index/type/id) -d '{ "array" : ["a", "b"] }'
> 
> I now perform a term search for the document using one of the elements in the array.
> 
> $ curl -XGET "[http://localhost:9200/\_search?q=array:a&pretty](http://localhost:9200/_search?q=array:a&pretty)"  
> {  
> "took" : 1,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 0,  
> "max\_score" : null,  
> "hits" :   
> }  
> }
> 
> It doesn't find the document. If I repeat the about experiment with two character strings, the document is found. Is there a limit to how short a string can be matched in an array?
> 
> ## Cheers, Tony

--

---

<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, 3:05am UTC](https://discuss.elastic.co/t/matching-arrays-of-single-character-strings/9613/3 "2017-07-06T03:05:33Z")

</div>


