Matching arrays of single character strings

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 -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"
{
"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

--

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 :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 8 nov. 2012 à 00:42, Tony Edgin 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 -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"
{
"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

--