Skip to content
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

Allow passing a query in Terms Query's "Terms lookup mechanism" #23713

Closed
gcampbell-epiq opened this issue Mar 23, 2017 · 3 comments
Closed

Allow passing a query in Terms Query's "Terms lookup mechanism" #23713

gcampbell-epiq opened this issue Mar 23, 2017 · 3 comments

Comments

@gcampbell-epiq
Copy link

Describe the feature: Extend the Terms Query to allow another query to be used as the "Terms lookup mechanism."

Currently, a specific document can be referenced from the terms query as a means of passing a lot of values to the terms query. Documented here: Terms Query - Terms lookup mechanism. I'm proposing making the lookup's "id" parameter optional, and adding a "query" parameter which supports the full query DSL.

This would give ElasticSearch a functional equivalent to this common SQL statement.

SELECT * 
FROM TableA a
WHERE a.Field1 IN (SELECT DISTINCT b.Field2
                   FROM TableB b
                   WHERE b.Field3 LIKE '%blah%')
-- TableA & TableB could of course be the same table
-- Field1, Field2, and Field3 could of course be the same field

Given my proposed change to the terms query, the equivalent in ES Query DSL to this SQL would be:

POST /TableA/_search
{
    "query": {
        "terms": {
            "Field1": {
                "path": "Field2",
                "index": "TableB",
                "query": { //query parameter here, instead of id parameter
                    "query_string": { "query": "*blah*", "default_field": "Field3" }
                }
            }
        }
    }
}
@gcampbell-epiq
Copy link
Author

I know this could be accomplished with multiple calls, but I'm afraid of the overhead in that.

@wenhoujx
Copy link

#3278

@clintongormley
Copy link

As @wenhoujx pointed out, we decided not to add this functionality in #3278 because it is not horizontally scalable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants