Reputation: 1726
I am trying to fetch some details that match "ListExperiences.Title" using a query from my elastic
{
"size": 100,
"query": {
"match_phrase": {
"ListExperiences.Title": "technical specialist"
}
},
"_source":["skillstop"]
}
I was able to execute successfully and i got the required results.
{...
"hits":[{
...
"_source":{"skillstop": "government, active directory"
} }
]}
the length of hits = 1 as i made only query. But if I want to run for such five titles, eg: "support specialist", "technical expert", "technical specialist", "customer care respentative", I have to run the elasticsearch 5 times.
is there any way that I can run all at one time? (expecting i get length of hits = 5)
I tried like this
{
"size": 100,
"query": {
"dis_max":{
"queries":[
{"match_phrase": {
"ListExperiences.Title": "technical specialist"} },
{"match_phrase": {
"ListExperiences.Title": "technical expert"} }
]
}
}
}
it is returning only the "technical expert" or what ever is the last one.
Upvotes: 0
Views: 48
Reputation: 3212
It depends. If you want to launch an or query, you should try:
{
"query" : {
"bool" : {
"should": [{
"match_phrase": {
"ListExperiences.Title": "technical specialist"
}
}, {
"match_phrase": {
"ListExperiences.Title": "technical expert"
}
}]
}
}
}
If you want to make more than one query with only one POST request, you should use multi_search
- doc here
GET <your_index_name>/_msearch
{"query" : {"match_phrase" : {"ListExperiences.Title": "technical specialist"}}}
{"query" : {"match_phrase" : {"ListExperiences.Title": "technical expert"}}}
Upvotes: 1