Terms filter lookup example not working


(Or Weinberger) #1

Hi,

Running the latest version (1.5.2) and following this topic: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html#_terms_lookup_twitter_example

However, even though I'm doing everything exactly as it says in the example, I'm getting 0 hits:

{
    "took": 1,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "failed": 0
    },
    "hits": {
        "total": 0,
        "max_score": null,
        "hits": []
    }
}

(Mark Walkom) #2

That's right, because you only have a tweet belonging to user 2 and that user only follows users 1 and 3 and not themselves. So if you ask for all tweets for users that user 2 follows, ie user 1 and 3, it won't return anything.

It just illustrates that the query will create a filter that ignores that tweet.

If you did;

$ curl -XPUT localhost:9200/tweets/tweet/2 -d '{
   "user" : "1"
}'

And then rerun that query, you will get a result as it matches the filter.


(system) #3