Incorrectly convert nested query
See original GitHub issuePUT index
{
"mappings": {
"my_case": {
"properties": {
"events": {
"type": "nested"
}
}
}
}
}
I made mapping structure like this. every row has more than two events data and would like to find one of events that matches poid and oid.
select name from my_case where (events.poid='A' and events.oid='B');
This is how I tried to query through sql4es, but It seems not results as I expected.
from sql4es
{
"size": 200,
"timeout": 10000,
"post_filter": {
"bool": {
"must": [
{
"nested": {
"query": {
"term": {
"events.poid": "A"
}
},
"path": "events"
}
},
{
"nested": {
"query": {
"term": {
"events.oid": "B"
}
},
"path": "events"
}
}
]
}
}
}
It found every events that has poid is ‘A’ OR oid is ‘B’. How should I made query to find matching both condition?
This is what I want to make through sql4es
.....
"query": {
"nested": {
"path": "events",
"filter": {
"bool" : {
"must" : [
{"term" : { "events.poid" : "A"}},
{"term" : { "events.oid" : "B"}}
]
}
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Convert a nested subquery into normal query - Stack Overflow
I have problem with following query where in which the nested query should be converted to normal query: select count(*) as count, ...
Read more >how can I convert this SQL statement with nested IN clauses to ...
You can get this by changing each IN subquery into a join, and matching the columns in the join condition. SELECT Q.* FROM...
Read more >how to convert nested query to join - Oracle Communities
I wrote a query, at first i find the name of the highest mountain,then find its provience and then list of mountains in...
Read more >Avoid automatic convert nested queries to joins #27267 - GitHub
This is not converting nested query to joins. The subquery returns single scalar result and is placed directly into projection because a scalar ......
Read more >Writing Subqueries in SQL | Advanced SQL - Mode Analytics
Subqueries (also known as inner queries or nested queries) are a tool for performing operations in multiple steps. For example, if you wanted...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for your thorough explanation of the problem! I understand the issue and my guess right now is that it is a bug in the driver which I will have to verify. The last example in your post is exactly what it should be and ill look into it (might be a bit tricky to get it done though so will take some time)
Everything are solved with kind explanation 😃