Nested bool query with multiple must and shouldMultiple values in QueryString query using elasticsearch NESTElasticsearch query_string nested queryElasticsearch difference between MUST and SHOULD bool queryQuery two fields, one nested and one on the rootElastic Search: use filter and should bool query'must' and 'should' combined in bool query not workingMultiple Paths in Nested QueriesWill ElasticSearch performance differ if we have multiple nested queriesMultiple nested queries to the same path?Filtering query in elastic search for nested model
Is there a term for the belief that "if it's legal, it's moral"?
Did the CIA blow up a Siberian pipeline in 1982?
Non-misogynistic way to say “asshole”?
Too early in the morning to have SODA?
Can the pre-order traversal of two different trees be the same even though they are different?
Why is oilcloth made with linseed oil?
Methodology: Writing unit tests for another developer
Is there official documentation on directories like ~/.config and ~/.cache?
How do I remove this inheritance-related code smell?
Why don't countries like Japan just print more money?
Draw a symmetric alien head
How do I see debug logs for Change Data Capture triggers in Salesforce?
Why isn't my calculation that we should be able to see the sun well beyond the observable universe valid?
Do I have any obligations to my PhD supervisor's requests after I have graduated?
A word for delight at someone else's failure?
What is "industrial ethernet"?
"Correct me if I'm wrong"
Drawing a second weapon as part of an attack?
Is "Busen" just the area between the breasts?
Subtract the Folded Matrix
How can I prevent a user from copying files on another hard drive?
What is the most suitable position for a bishop here?
What was the first third-party commercial application for MS-DOS?
Novel in which alien (Martian?) is trapped on Earth in prehistory
Nested bool query with multiple must and should
Multiple values in QueryString query using elasticsearch NESTElasticsearch query_string nested queryElasticsearch difference between MUST and SHOULD bool queryQuery two fields, one nested and one on the rootElastic Search: use filter and should bool query'must' and 'should' combined in bool query not workingMultiple Paths in Nested QueriesWill ElasticSearch performance differ if we have multiple nested queriesMultiple nested queries to the same path?Filtering query in elastic search for nested model
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Look at my use case below
Two nested fields
base1.point1
base1.point2
base1.point3
base1.point4
and
base2.point1
base2.point2
base2.point3
base2.point4
search condition
(
(base1.point1 AND base1.point2) OR (base1.point2 AND base1.point3)
)
AND
(
(base2.point1 AND base2.point2) OR (base2.point2 AND base2.point3)
)
Please help for writing above in a single query.
elasticsearch elastic-stack
add a comment |
Look at my use case below
Two nested fields
base1.point1
base1.point2
base1.point3
base1.point4
and
base2.point1
base2.point2
base2.point3
base2.point4
search condition
(
(base1.point1 AND base1.point2) OR (base1.point2 AND base1.point3)
)
AND
(
(base2.point1 AND base2.point2) OR (base2.point2 AND base2.point3)
)
Please help for writing above in a single query.
elasticsearch elastic-stack
add a comment |
Look at my use case below
Two nested fields
base1.point1
base1.point2
base1.point3
base1.point4
and
base2.point1
base2.point2
base2.point3
base2.point4
search condition
(
(base1.point1 AND base1.point2) OR (base1.point2 AND base1.point3)
)
AND
(
(base2.point1 AND base2.point2) OR (base2.point2 AND base2.point3)
)
Please help for writing above in a single query.
elasticsearch elastic-stack
Look at my use case below
Two nested fields
base1.point1
base1.point2
base1.point3
base1.point4
and
base2.point1
base2.point2
base2.point3
base2.point4
search condition
(
(base1.point1 AND base1.point2) OR (base1.point2 AND base1.point3)
)
AND
(
(base2.point1 AND base2.point2) OR (base2.point2 AND base2.point3)
)
Please help for writing above in a single query.
elasticsearch elastic-stack
elasticsearch elastic-stack
edited Mar 25 at 7:14
emix
7,48753254
7,48753254
asked Mar 25 at 7:09
G2KG2K
127
127
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Note that I'm assuming that when you meant nested you are actually talking about Nested Datatype and not plain Object Datatype
Also looking at your question, you are only concerned if the nested fields exists or not, regardless of their values. For such use cases you would need to make use of Exists Query.
Below is how my Nested Query would be:
POST <you_index_name>/_search
"query":
"bool":
"must":[
"bool":
"should":[
"bool":
"must":[
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point1"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point2"
]
,
"bool":
"must":[
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point2"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point3"
]
]
,
"bool":
"should":[
"bool":
"must":[
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point1"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base2.point2"
]
,
"bool":
"must":[
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point2"
,
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point3"
]
]
]
Hope this helps!
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55332738%2fnested-bool-query-with-multiple-must-and-should%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Note that I'm assuming that when you meant nested you are actually talking about Nested Datatype and not plain Object Datatype
Also looking at your question, you are only concerned if the nested fields exists or not, regardless of their values. For such use cases you would need to make use of Exists Query.
Below is how my Nested Query would be:
POST <you_index_name>/_search
"query":
"bool":
"must":[
"bool":
"should":[
"bool":
"must":[
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point1"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point2"
]
,
"bool":
"must":[
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point2"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point3"
]
]
,
"bool":
"should":[
"bool":
"must":[
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point1"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base2.point2"
]
,
"bool":
"must":[
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point2"
,
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point3"
]
]
]
Hope this helps!
add a comment |
Note that I'm assuming that when you meant nested you are actually talking about Nested Datatype and not plain Object Datatype
Also looking at your question, you are only concerned if the nested fields exists or not, regardless of their values. For such use cases you would need to make use of Exists Query.
Below is how my Nested Query would be:
POST <you_index_name>/_search
"query":
"bool":
"must":[
"bool":
"should":[
"bool":
"must":[
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point1"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point2"
]
,
"bool":
"must":[
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point2"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point3"
]
]
,
"bool":
"should":[
"bool":
"must":[
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point1"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base2.point2"
]
,
"bool":
"must":[
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point2"
,
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point3"
]
]
]
Hope this helps!
add a comment |
Note that I'm assuming that when you meant nested you are actually talking about Nested Datatype and not plain Object Datatype
Also looking at your question, you are only concerned if the nested fields exists or not, regardless of their values. For such use cases you would need to make use of Exists Query.
Below is how my Nested Query would be:
POST <you_index_name>/_search
"query":
"bool":
"must":[
"bool":
"should":[
"bool":
"must":[
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point1"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point2"
]
,
"bool":
"must":[
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point2"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point3"
]
]
,
"bool":
"should":[
"bool":
"must":[
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point1"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base2.point2"
]
,
"bool":
"must":[
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point2"
,
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point3"
]
]
]
Hope this helps!
Note that I'm assuming that when you meant nested you are actually talking about Nested Datatype and not plain Object Datatype
Also looking at your question, you are only concerned if the nested fields exists or not, regardless of their values. For such use cases you would need to make use of Exists Query.
Below is how my Nested Query would be:
POST <you_index_name>/_search
"query":
"bool":
"must":[
"bool":
"should":[
"bool":
"must":[
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point1"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point2"
]
,
"bool":
"must":[
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point2"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base1.point3"
]
]
,
"bool":
"should":[
"bool":
"must":[
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point1"
,
"nested":
"path":"base1",
"query":
"exists":
"field":"base2.point2"
]
,
"bool":
"must":[
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point2"
,
"nested":
"path":"base2",
"query":
"exists":
"field":"base2.point3"
]
]
]
Hope this helps!
edited Mar 25 at 9:00
answered Mar 25 at 8:43
KamalKamal
3,40721023
3,40721023
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55332738%2fnested-bool-query-with-multiple-must-and-should%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown