-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Query DSL: Terms filter to allow for terms lookup from another document #2674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This nearly finishes/fixes the feature issue #2671 |
In this example, shouldn't tweet/1 have user "1" or "3"? This example doesn't return hits for me but it does when I change it to 1 or 3. I have a gist here: https://gist.github.com/telvis07/5469479 |
@kimchy Quick question about using this feature vs using the IDs filter I will probably implement both for benchmark purpose but would love to hear from your feedback! |
If you index the terms into ES, and use the "external terms filter", you
clint On 17 May 2013 21:51, Loris Guignard [email protected] wrote:
|
This is a very useful feature. Just curious whether it's possible to generalize this to support JOIN. In the case of join, the list of lookup terms is not fetched from another document, but rather it's the result of a query from a related document. Replicating this related document in all nodes can also eliminate networking. I have a use case where I need to embed a particular document under another related document as nested doc. As it is a many-to-many relationship, this embedding introduced a huge number of redundant docs. If JOIN is supported, I will not need to embed the actual doc, include a field keeping the related doc IDs will be sufficient. It seems Solr supports join in a similar fashion: http://wiki.apache.org/solr/Join. It is somewhat limited, but if used properly, it can be very helpful. |
@junjun-zhang see #3278. Hopefully @martijnvg and @kimchy will get a chance to have a look at this soon. |
In this example:
Say I wanted to pass an array of ids instead of a single id as it's shown Reason is I have several documents I want to combine. |
@brupm then just use several terms lookup filters, wrapped in a |
Is there an upper limit on who many terms filters I can have wrapped in a bool.should? @clintongormley - thank you! |
Probably 1024, which should be more than enough... |
please provide a suggestion on this Index 1 and index 2 had common entity (Ex. Empl no.) |
I am getting only 400 even if the lookup type has 524 documnts. any suggestion on what could be wrong. below is the query |
The terms filter requires providing all the terms as part of the filter itself. Allow to automatically extract them from an external document.
Here is an example:
The above is higly optimized, both in a sense that the list of friends will not be fetched if the filter is already cached in the filter cache, and with internal LRU cache for fetching external values for the terms filter. Also, the entry in teh filter cache will not hold all the terms reducing the memory required for it.
_cache_key
is recommedned to be set, so its simple to clear the cache associated with it using the clear cache API. For example:The structure of the external terms document can also include array of inner objects, for example:
In which case, the lookup path will be
friends.id
.There is an additional cache involved, which caches the lookup of the lookup document to the actual terms. It is by default set to
10mb
LRU size, but can be explicitly set usingindices.cache.filter.terms.size
.Also, consider using an index with a single shard and fully replicated across all nodes if the "reference" terms data is not large. The lookup terms filter will prefer to execute the get request on a local node if possible, reducing the need for networking.
The text was updated successfully, but these errors were encountered: