Skip to main content
added 283 characters in body
Source Link
user5054
  • 1.1k
  • 1
  • 9
  • 23

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" }}
                  ]
            }
        }
    }
  }

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 one I tried, and gives RequestError(400, 'parsing_exception', '[term] query does not support [name]').

"query": {
   "term": {
     "person1": {
       "name": "John White",
       "job": "teacher"
     },
     "person2": {
       "name": "Sarah Black",
       "job": "doctor"
     }
   }
  }

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 below query but it gives me pairs where only 1 of the pairs matches the info I ask for, the other person's name/job could be very different. How to get an exact match where both persons' info matches?

  "query": {
    "bool" : {
        "must": {
            "bool" : {
                "should": [
                    { "match": { "person1.name": "John White" }},
                    { "match": { "person1.job": "teacher" }}
                  ],
                "should": [
                    { "match": { "person2.name": "Sarah Black" }},
                    { "match": { "person2.job": "doctor" }}
                  ]
            }
        }
    }
  }
added 251 characters in body
Source Link
user5054
  • 1.1k
  • 1
  • 9
  • 23

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 one I tried, and gives RequestError(400, 'parsing_exception', '[term] query does not support [name]').

"query": {
   "term": {
     "person1": {
       "name": "John White",
       "job": "teacher"
     },
     "person2": {
       "name": "Sarah Black",
       "job": "doctor"
     }
   }
  }

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.

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 one I tried, and gives RequestError(400, 'parsing_exception', '[term] query does not support [name]').

"query": {
   "term": {
     "person1": {
       "name": "John White",
       "job": "teacher"
     },
     "person2": {
       "name": "Sarah Black",
       "job": "doctor"
     }
   }
  }
Source Link
user5054
  • 1.1k
  • 1
  • 9
  • 23

How to create an ElasticSearch query to get this information?

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.