-
Notifications
You must be signed in to change notification settings - Fork 49
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
[FEATURE] - Performing complex relational queries is merely impossible. #446
Comments
Correcting myself on this statement :
Turns out, the SQL plugin has the same (or similar) issues (check bullet #4): Quoting the page :
So, using the SQL plugin does not seem to be a viable solution at all. |
And on a second review, using C# expressions does not seem like a good idea (too many limitations).
But I am not 100% sure how one could exclude specific nested queries from being "relationalized". |
I have started experimenting on an implementation for this. |
I have a working implementation of this, that also adds some extra tiny features. One thing that I had to do was to add a way of cloning I am planning to add some tests as well, but I have various issues with Visual Studio not running the tests. There were also some "challenges" with preserving the scoring behavior with This is how it works now:
|
@DumboJetEngine for ease of review and change tracking purpose, it would best that they're separate PRs please |
@Xtansia |
Is your feature request related to a problem?
While trying to translate some SQL relational queries into OpenSearch queries using nested documents and the
OpenSearch.Client
, I got into MANY problems due to the fact that I had to gather all nested fields under a single nested query.I wrote a question here, but I am not sure if is clear enough.
Essentially, when the SQL query is complex and involves many JOINed tables, the nested queries in OpenSearch become too complex to write by hand.
For example, say you have this SQL query:
To translate that into an OpenSearch query, after you create the nested documents for
t1
&t2
, you have to gather allt1
filters under a single nested query, all thet2
filters under another nested query, and all non-nested field filters outside the nested queries.By doing some manual boolean transformations one could shape the query like that:
This gets very easily out of hand for more complex queries, and even more for dynamic queries where you cannot statically analyze and simplify the queries beforehand.
What solution would you like?
A way to preprocess queries, in order to gather all nested fields under a single nested query would be great, since this cannot be done manually most of the times.
In the example above, it would be great if the mentioned query "simplification" and gathering of all:
t1
filters under a single nested queryt2
filters under another single nested queryd
filters outside all nested queries...could be performed by the library. Also, when using property attributes/annotations for the nested object, the library could infer by itself when to use a nested query and when not, without having the programmer specify anything extra.
I guess it is a complex feature, but at least I hope I have explained well what the problem is.
If I am missing something (because I am quite new to OpenSearch), let me know.
The way I am imagining the implementation is something like this, which uses C# Expression trees in the
.Relational()
method:I guess a similar feature must already exist in the SQL plugin for OS, since that problem would also be present there and had to be solved somehow, although the SQL plugin has some restrictions from what I can recall.
What alternatives have you considered?
inner_hits
from each nested query in my query to eliminate some returned results : it was not feasible since I had many nested queries and nested documents queried in a single convoluted query.OpenSearch.Client
: this is not possible since my queries are built dynamically, I have more than 2 nested objects, etc.The text was updated successfully, but these errors were encountered: