Skip to content

Instantly share code, notes, and snippets.

@djptek
Last active December 18, 2019 13:27
Show Gist options
  • Save djptek/aee650185e882a7f373107d92d2fa5d1 to your computer and use it in GitHub Desktop.
Save djptek/aee650185e882a7f373107d92d2fa5d1 to your computer and use it in GitHub Desktop.
script query equal properties
PUT test_eq/_doc/test_pass
{
"property1": "foo",
"property2": "foo"
}
PUT test_eq/_doc/test_fail
{
"property1": "foo",
"property2": "bar"
}
GET test_eq/_search
{
"query": {
"bool": {
"filter": {
"script": {
"script": {
"source": "doc['property1.keyword'].value == doc['property2.keyword'].value",
"lang": "painless"
}
}
}
}
}
}
##### shorter version
GET test_eq/_search
{
"query": {
"script": {
"script": {
"source": "doc['property1.keyword'].value == doc['property2.keyword'].value",
"lang": "painless"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment