CopyPastor

Detecting plagiarism made easy.

Score: 0.8066865801811218; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2021-09-08
by ESCoder

Original Post

Original - Posted on 2019-06-01
by niranjan\_harpale



            
Present in both answers; Present only in the new answer; Present only in the old answer;

[`filter` and `must`][1] clauses both work as a logical AND operator. The only difference is that in the `filter` clause the scoring is ignored, whereas in the `must` clause the matched documents contribute to the scoring.
You can either wrap your bool must query inside the filter clause, as shown below
{ "query": { "bool": { "filter": { "bool": { "must": [ { "term": { "name.keyword": "John Doe" } }, { "terms": { "state.keyword": [ "AZ", "CA" ] } } ] } } } } }
Or you can replace the `must` clause with the `filter` clause
{ "query": { "bool": { "filter": [ { "term": { "name.keyword": "John Doe" } }, { "terms": { "state.keyword": [ "AZ", "CA" ] } } ] } } }

[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
This is how you can nest multiple bool queries in one outer bool query this using Kibana,
* **bool** indicates we are using boolean * **must** is for **AND** * **should** is for **OR**
``` GET my_inedx/my_type/_search { "query" : { "bool": { //bool indicates we are using boolean operator "must" : [ //must is for **AND** { "match" : { "description" : "some text" } }, { "match" :{ "type" : "some Type" } }, { "bool" : { //here its a nested boolean query "should" : [ //should is for **OR** { "match" : { //ur query } }, { "match" : {} } ] } } ] } } } ``` This is how you can nest a query in ES <hr>
There are more types in "bool" like, 1. Filter 2. must_not

        
Present in both answers; Present only in the new answer; Present only in the old answer;