Skip to content

Instantly share code, notes, and snippets.

@prashanth-sams
Last active December 16, 2018 10:59
Show Gist options
  • Select an option

  • Save prashanth-sams/0c452baff6d2d46ea0910a548bc51738 to your computer and use it in GitHub Desktop.

Select an option

Save prashanth-sams/0c452baff6d2d46ea0910a548bc51738 to your computer and use it in GitHub Desktop.
Elastic search queries with condition
GET /your_path/_search
{
"size": 5,
"_source": [ "expected_key1", "expected_key2", "..."],
"query": {
"bool": {
"should": [
{
"term": {
"expected_key": expected_value
}
},
{
"term": {
"expected_key": expected_value
}
}
]
}
}
}
GET /your_path/_search
{
"size": 5,
"_source":["expected_key1","expected_key2", "..."],
"query": {
"bool": {
"must_not": [
{
"term": {
"expected_key": expected_value
}
}
],
"should": [
{
"term": {
"expected_key": expected_value
}
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment