Underscores in search term


(Katrina) #1

This is the behavior that I'm observing:

With the following two records:

curl -XPUT 'http://localhost:9200/craft/project/1' -d '
{
"kiddo" : "wendy",
"category" : "art_doll",
"material" : "felt",
"title" : "A pretty doll"
}
'
curl -XPUT 'http://localhost:9200/craft/project/2' -d '
{
"kiddo" : "wendy",
"category" : "art_box",
"material" : "cardboard",
"title" : "A functional box"
}
'

If I do a term query on category for "art_doll" I get zero results
back. If I query for "art" I get two results back.

I thought maybe term would return documents where the category was a
partial match for the word (art_box, art_doll), but then I would have
expected the materials query to return 1 result for "card", matching
on the word "cardboard", but I get 0 results back for "card".

These are the actual queries that I am running against the two
documents indexed above:
On the other hand, if I do a term query on "material" for "card", I
get zero results back.

curl -XGET http://127.0.0.1:9200/craft/project/_search -d '
{
"query" : {
"filtered" : {
"query" : {
"term" : { "kiddo" : "wendy" }
},
"filter" : {
"term" : {"category" : "art_box"}
}
}
}
}
'

=> 0 results

curl -XGET http://127.0.0.1:9200/craft/project/_search -d '
{
"query" : {
"filtered" : {
"query" : {
"term" : { "kiddo" : "wendy" }
},
"filter" : {
"term" : {"category" : "art"}
}
}
}
}
'

=> 2 results

curl -XGET http://127.0.0.1:9200/craft/project/_search -d '
{
"query" : {
"filtered" : {
"query" : {
"term" : { "kiddo" : "wendy" }
},
"filter" : {
"term" : {"material" : "cardboard"}
}
}
}
}
'

=> 1 result

curl -XGET http://127.0.0.1:9200/craft/project/_search -d '
{
"query" : {
"filtered" : {
"query" : {
"term" : { "kiddo" : "wendy" }
},
"filter" : {
"term" : {"material" : "card"}
}
}
}
}
'

=> 0 result

I'd appreciate any pointers as to what the underlying mechanism is, as
well as how to do a match against a field like "art_box".

Thanks!
Katrina


(system) #2