Last active
August 16, 2017 13:13
-
-
Save sajidzaman/341a520efccde2523e2238c2e62a2396 to your computer and use it in GitHub Desktop.
Elastic search Filters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET courses/_search | |
{ | |
"query" :{ | |
"bool":{ | |
"filter" :{ | |
"match": {"name": "accounting"} | |
} | |
} | |
} | |
} | |
Filters does not do relevancy scoring | |
Primarilary used for fetching the data. | |
Filters are cached. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET courses/_search | |
{ | |
"query" :{ | |
"bool":{ | |
"filter" :{ | |
"bool":{ | |
"must":[ | |
{"match": {"name": "accounting"}} | |
] | |
} | |
}, | |
"must": [ | |
{"match": {"room":"e3"}} | |
] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET courses/_search | |
{ | |
"query" :{ | |
"bool":{ | |
"filter" :{ | |
"bool":{ | |
"must":[ | |
{"match": {"name": "accounting"}}, | |
{"match": {"professor.name": "bill"}} | |
] | |
} | |
} | |
} | |
} | |
} | |
Use of Must in filter | |
GET courses/_search | |
{ | |
"query" :{ | |
"bool":{ | |
"filter" :{ | |
"bool":{ | |
"must":[ | |
{"match": {"name": "accounting"}}, | |
{"match": {"professor.name": "bill"}} | |
], | |
"must_not": [ | |
{"match": {"room":"e7"}} | |
] | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET courses/_search | |
{ | |
"query" :{ | |
"bool":{ | |
"filter" :{ | |
"bool":{ | |
"must":[ | |
{"match": {"name": "accounting"}} | |
] | |
} | |
}, | |
"should": [ | |
{"match": {"room":"e3"}} | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment