I need to query an ElasticSearch index through the Python module and I am pretty unfamiliar with ElasticSearch. Say my index stores pairs of persons and some information about each pair. I wonder how to create an ElasticSearch query which would give me below pair. Basically, I want to get the some info field value from the pair where person1 is named John White and a teacher and person2 is named Sarah Black and a doctor. I want an exact match, not a fuzzy one.
"person1": {
"name": "John White",
"job": "teacher"
}
"person2": {
"name": "Sarah Black",
"job": "doctor"
}
"some info": "blah blah"
I tried several queries based on what I read online with no luck. I keep getting parsing error. Below is onebelow query but it gives me pairs where only 1 of the pairs matches the info I triedask for, and gives RequestError(400, 'parsing_exception', '[term] query does not support [name]')the other person's name/job could be very different. How to get an exact match where both persons' info matches?
"query": {
"term" "bool" : {
"person1" "must": {
"name" "bool" : {
"should": [
{ "match": { "person1.name": "John White" }},
"job" { "match": { "person1.job": "teacher" }}
} ],
"person2" "should": {[
"name" { "match": { "person2.name": "Sarah Black" }},
"job" { "match": { "person2.job": "doctor" }}
]
}
}
}
}