String with numbers fails

ES Version: 0.20.6
Platform: Bodhi Linux, single instance

I'm still learning ES, so excuse me if this is a basic mistake with my
understanding of how ES works
I have created an index with name mastercatalog, Refer this gist for the
details and have loaded a sample set of data

Following Query works, but if I replace "name" with "partnumber" I don't
seem to get any results back
It almost appears that only if my field value is a string (with all
characters) it seems to return results, but if my string has some numbers
in it I don't get
a response back.

Request:
curl -XPOST 'http://localhost:9200/mastercatalog/_search?pretty=true' -d '{
"query": {
"filtered": {
"query": {
"bool": {
"must": [{"term": {"name" :"auchan" }}]
}
},
"filter": {
"has_child": {
"type": "product",
"query": {
"filtered": {
"query": {
"bool": {
"must": [{"term": {"name": "toys"}}]
}
},
"filter": {
"has_child": {
"type": "variation",
"query": {
"term": {
"trademark": "tiger"
}
}
}
}
}
}
}
}
}
}
}'

Response:

{ "took" : 12, "timed_out" : false, "_shards" : { "total" : 5, "successful"
: 5, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 1.4054651,
"hits" : [ { "_index" : "mastercatalog", "_type" : "10101", "_id" :
"10101", "_score" : 1.4054651, "_source" : { "name" : "auchan", "owner" :
"chris" } } ] } }

Request that does not work (I replaced{"name": "toys"} with {"partnumber":
"EI-01G-1"}):

curl -XPOST 'http://localhost:9200/mastercatalog/_search?pretty=true' -d '{
"query": { "filtered": { "query": { "bool": { "must": [{"term": {"name"
:"auchan" }}] } }, "filter": { "has_child": { "type": "product", "query": {
"filtered": { "query": { "bool": { "must": [{"term": {"partnumber":
"EI-01G-1"}}] } }, "filter": { "has_child": { "type": "variation", "query":
{ "term": { "trademark": "tiger" } } } } } } } } } } }'

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

It's because your field is analyzed (aka break into tokens).
Change you analyzer for this field to not analyzed for example. Something like:
$ curl -XPUT 'http://localhost:9200/twitter/tweet/_mapping' -d '
{
"tweet" : {
"properties" : {
"message" : {"type" : "string", "index" : "not_analyzed"}
}
}
}
'

Then, you will be to search for the exact value you sent.

Does it help?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 11 avr. 2013 à 16:54, Hariharan Vadivelu hariinfo@gmail.com a écrit :

ES Version: 0.20.6
Platform: Bodhi Linux, single instance

I'm still learning ES, so excuse me if this is a basic mistake with my understanding of how ES works
I have created an index with name mastercatalog, Refer this gist for the details and have loaded a sample set of data
elastic_parent_child.sh · GitHub

Following Query works, but if I replace "name" with "partnumber" I don't seem to get any results back
It almost appears that only if my field value is a string (with all characters) it seems to return results, but if my string has some numbers in it I don't get
a response back.

Request:
curl -XPOST 'http://localhost:9200/mastercatalog/_search?pretty=true' -d '{
"query": {
"filtered": {
"query": {
"bool": {
"must": [{"term": {"name" :"auchan" }}]
}
},
"filter": {
"has_child": {
"type": "product",
"query": {
"filtered": {
"query": {
"bool": {
"must": [{"term": {"name": "toys"}}]
}
},
"filter": {
"has_child": {
"type": "variation",
"query": {
"term": {
"trademark": "tiger"
}
}
}
}
}
}
}
}
}
}
}'

Response:

{
"took" : 12,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.4054651,
"hits" : [ {
"_index" : "mastercatalog",
"_type" : "10101",
"_id" : "10101",
"_score" : 1.4054651, "_source" : { "name" : "auchan", "owner" : "chris" }
} ]
}
}

Request that does not work (I replaced{"name": "toys"} with {"partnumber": "EI-01G-1"}):

curl -XPOST 'http://localhost:9200/mastercatalog/_search?pretty=true' -d '{
"query": {
"filtered": {
"query": {
"bool": {
"must": [{"term": {"name" :"auchan" }}]
}
},
"filter": {
"has_child": {
"type": "product",
"query": {
"filtered": {
"query": {
"bool": {
"must": [{"term": {"partnumber": "EI-01G-1"}}]
}
},
"filter": {
"has_child": {
"type": "variation",
"query": {
"term": {
"trademark": "tiger"
}
}
}
}
}
}
}
}
}
}
}'

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Excellent, That fixed the problem.
Updated gist elastic_parent_child.sh · GitHub

On Thursday, April 11, 2013 9:54:48 AM UTC-5, Hariharan Vadivelu wrote:

ES Version: 0.20.6
Platform: Bodhi Linux, single instance

I'm still learning ES, so excuse me if this is a basic mistake with my
understanding of how ES works
I have created an index with name mastercatalog, Refer this gist for the
details and have loaded a sample set of data
elastic_parent_child.sh · GitHub

Following Query works, but if I replace "name" with "partnumber" I don't
seem to get any results back
It almost appears that only if my field value is a string (with all
characters) it seems to return results, but if my string has some numbers
in it I don't get
a response back.

Request:
curl -XPOST 'http://localhost:9200/mastercatalog/_search?pretty=true' -d
'{
"query": {
"filtered": {
"query": {
"bool": {
"must": [{"term": {"name" :"auchan" }}]
}
},
"filter": {
"has_child": {
"type": "product",
"query": {
"filtered": {
"query": {
"bool": {
"must": [{"term": {"name": "toys"}}]
}
},
"filter": {
"has_child": {
"type": "variation",
"query": {
"term": {
"trademark": "tiger"
}
}
}
}
}
}
}
}
}
}
}'

Response:

{ "took" : 12, "timed_out" : false, "_shards" : { "total" : 5,
"successful" : 5, "failed" : 0 }, "hits" : { "total" : 1, "max_score" :
1.4054651, "hits" : [ { "_index" : "mastercatalog", "_type" : "10101",
"_id" : "10101", "_score" : 1.4054651, "_source" : { "name" : "auchan",
"owner" : "chris" } } ] } }

Request that does not work (I replaced{"name": "toys"} with {"partnumber":
"EI-01G-1"}):

curl -XPOST 'http://localhost:9200/mastercatalog/_search?pretty=true' -d
'{ "query": { "filtered": { "query": { "bool": { "must": [{"term": {"name"
:"auchan" }}] } }, "filter": { "has_child": { "type": "product", "query": {
"filtered": { "query": { "bool": { "must": [{"term": {"partnumber":
"EI-01G-1"}}] } }, "filter": { "has_child": { "type": "variation", "query":
{ "term": { "trademark": "tiger" } } } } } } } } } } }'

--
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.
For more options, visit https://groups.google.com/groups/opt_out.