Reputation: 5423
consider the following index of ES
{
"hits": {
"total": 5,
"max_score": 1,
"hits": [
{
"_source": {
"name": "A",
"postalCode": {
"code": "postcodeA",
"validated": false
}
}
},
{
"_source": {
"name": "B",
"postalCode": {
"code": "postcodeB",
"validated": true
}
}
}
]
}
}
how do I search for hits with condition:
_source.postalCode.validated=true
I'm still new and trying to get used to ES. some of the queries that I've tried are the followings:
q=_source.pastalCode.validated=true
q=_source.postalCode.validated
q=_source:postalCode:validated
Upvotes: 0
Views: 40
Reputation: 7472
You can either perform a DSL query like so:
{
"query": {
"filtered": {
"filter": {
"term": {
"postalCode.validated": "true"
}
}
}
}
}
Or using the querystring, as you tried above:
q=postalCode.validated: true
You do not need to include the _source
part.
Upvotes: 1