# External doc terms query not giving any results

**URL:** <https://discuss.elastic.co/t/external-doc-terms-query-not-giving-any-results/349>\
**Category:** Elasticsearch\
**Created:** [May 7, 2015, 5:27pm UTC](https://discuss.elastic.co/t/external-doc-terms-query-not-giving-any-results/349 "2015-05-07T17:27:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![varun\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varun_kumar/32/24170_2.png) [@varun\_kumar](https://discuss.elastic.co/u/varun_kumar)\
**Post date:** [May 7, 2015, 5:27pm UTC](https://discuss.elastic.co/t/external-doc-terms-query-not-giving-any-results/349/1 "2015-05-07T17:27:03Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:15am UTC](https://discuss.elastic.co/t/external-doc-terms-query-not-giving-any-results/349/2 "2017-07-06T00:15:10Z")

</div>


