Kirtash
(Sergi)
June 8, 2017, 2:52pm
1
Hello!
I have this register (is a fragment):
"_index": "worker",
"_type": "work",
"_id": "055-008765",
"_score": 1,
"_source": {
"sex": "Women",
"name": "Nat",
"vehicles": [
"Car",
"Bus "
]
}
And I have this query:
"bool": {
"must": [
{
"terms": {
"vehicles": [
"car",
"bus"
]
}
}
]
I want all the workers that they have car AND bus, not one of them. How can I do it?
Thanks for all.
1 Like
dakrone
(Lee Hinman)
June 8, 2017, 9:18pm
2
Kirtash:
How can I do it?
You can do this either with a single match
query, or with a bool
as you mentioned, here's an example of both:
POST /_search
{
"query": {
"match": {
"vehicles": {
"query": "car bus",
"operator": "AND"
}
}
}
}
POST /_search
{
"query": {
"bool": {
"must": [
{"match": {"vehicles": "car"}},
{"match": {"vehicles": "bus"}}
]
}
}
}
system
(system)
Closed
July 6, 2017, 9:18pm
3
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.