Problem with termsQuerys


(agodoy) #1

Hola, I have problems using termsQuery

I do the following POSTs:
curl -XPUT 'http://localhost:9200/chages/charge/888888888' -d
'{"id":888888888,"currency_id":"VEF","quantity":1,"user_id":8181729,"type_id":"CP","comment":null,"amount":10,"reference_type":"items","reference_id":"MLV28100779","bill_id":15769805,"date_created":"2011-01-06T16:44:13.000-0400"}'
curl -XPUT 'http://localhost:9200/chages/charge/75848122' -d
'{"id":75848122,"currency_id":"VEF","quantity":1,"user_id":8181729,"type_id":"CP","comment":null,"amount":10,"reference_type":"items","reference_id":"MLV75848122","bill_id":15769805,"date_created":"2011-01-06T16:44:13.000-0400"}'

and then search with:
curl -XGET 'http://localhost:9200/charges/charge/_search?pretty=true' -d '{
"from" : 0,
"size" : 10,
"query" : {
"terms" : {
"reference_id" : [ "MLV28100779", "MLV75848122" ]
}
}
}'

but does not return results...
{
"took" : 6,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

the same happens with other fields like 'type_id' or 'reference_type'...
Please, any information is appreciated!!! Thanks!


(Shay Banon) #2

By default, text is analyzed, so something like MLV2812 ends up indexed as mlv2812. Terms (and term) filter/query do not perform analysis on the text, so, it ends up trying to match MLV2812 and does not find it (because mlv2812 is indexed). Sounds like for those you want exact matches, so use the mappings option to map those fields as not analyzed.

On Thursday, March 8, 2012 at 9:36 PM, Ana G wrote:

Hola, I have problems using termsQuery

I do the following POSTs:
curl -XPUT 'http://localhost:9200/chages/charge/888888888' -d '{"id":888888888,"currency_id":"VEF","quantity":1,"user_id":8181729,"type_id":"CP","comment":null,"amount":10,"reference_type":"items","reference_id":"MLV28100779","bill_id":15769805,"date_created":"2011-01-06T16:44:13.000-0400"}'
curl -XPUT 'http://localhost:9200/chages/charge/75848122' -d '{"id":75848122,"currency_id":"VEF","quantity":1,"user_id":8181729,"type_id":"CP","comment":null,"amount":10,"reference_type":"items","reference_id":"MLV75848122","bill_id":15769805,"date_created":"2011-01-06T16:44:13.000-0400"}'

and then search with:
curl -XGET 'http://localhost:9200/charges/charge/_search?pretty=true' -d '{
"from" : 0,
"size" : 10,
"query" : {
"terms" : {
"reference_id" : [ "MLV28100779", "MLV75848122" ]
}
}
}'

but does not return results...
{
"took" : 6,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

the same happens with other fields like 'type_id' or 'reference_type'...
Please, any information is appreciated!!! Thanks!


(system) #3