Hello All, hope someone can enlighten me on this one. Suppose I have the following data:
{ "index": { "_index": "courses_test", "_id": 1 } }
{ "Course Name": "Bachelor of Arts in Music", "Job Role": "Theatre & Media Director, Video Engineer" }
{ "index": { "_index": "courses_test", "_id": 2 } }
{ "Course Name": "Bachelor of Arts in Engineering", "Job Role": "Graduate policy officer, editorial assistant, communications and campaigns assistant, assistant advocacy officer, employment consultant." }
My objective is to match "Bachelor" AND "Engineering" in their Course Name AND Job Role fields. With the query below, not quite sure why 2 courses are being returned but document ID 2 does not satisfy the condition.
It works as expected if I search in "Course Name" only. Searching in "Job Role" returns 0, which is correct too.
I am using query string and using * so that even if the user just typed in prefixes e.g. 'bach eng', it should still match.
Full query:
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "Bachelor* AND Engineer*",
"fields": [
"Course Name",
"Job Role"
]
}
}
]
}
}
}
Response:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 2.0,
"hits": [
{
"_index": "courses_test",
"_type": "_doc",
"_id": "1",
"_score": 2.0,
"_source": {
"Course Name": "Bachelor of Arts in Music",
"Job Role": "Theatre & Media Director, Video Engineer"
}
},
{
"_index": "courses_test",
"_type": "_doc",
"_id": "2",
"_score": 2.0,
"_source": {
"Course Name": "Bachelor of Arts in Engineering",
"Job Role": "Graduate policy officer, editorial assistant, communications and campaigns assistant, assistant advocacy officer, employment consultant"
}
}
]
}
}
Thank you for your help!