External doc terms query not giving any results


(Varun Kumar) #1

I am trying to do "terms" query using document on other index as the source for search string. However I am not getting any hits.

-- index the information for user with id 2, specifically, its followers

curl -XPUT localhost:9200/users/user/2 -d '{
"followers" : ["1", "3"]
}'
-- index a tweet, from user with id 2

curl -XPUT localhost:9200/tweets/tweet/1 -d '{
"user" : "2"
}'
-- search on all the tweets that match the followers of user 2

curl -XGET localhost:9200/tweets/_search -d '{
"query" : {
"filtered" : {
"filter" : {
"terms" : {
"user" : {
"index" : "users",
"type" : "user",
"id" : "2",
"path" : "followers"
},
"_cache_key" : "user_2_friends"
}
}
}
}
}'
Result: 0 hits.

However if I change the query to:

{
"query" : {
"filtered" : {
"filter" : {
"terms" : {
"user" : [2]
}
}
}
}
}'
Above query gives me 1 hit, which means there is some problem with the external search query.

Details: http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html

I am using ES version: 1.5.2 also tried the query in 1.4.

Any suggestions?


(system) #2