But if its just one word, say sony in query data. The order is messed
up.
Based on your above statement and the comment which you mentioned in the above answer
Adding Working example with sample docs, and search query
Index Sample Data:
{
"MDMGlobalData":{
"name":"Sony Music"
}
}
{
"MDMGlobalData":{
"name":"Sony Music Corp"
}
}
{
"MDMGlobalData":{
"name":"All Sony Music Corp"
}
}
{
"MDMGlobalData":{
"name":"Sony"
}
}
Search Query:
{
"query": {
"query_string": {
"query": "(Sony) OR (Sony*) OR (*Sony) OR (*Sony*)",
"fields": [
"MDMGlobalData.name"
]
}
}
}
Search Result:
"hits": [
{
"_index": "foo1",
"_type": "_doc",
"_id": "4",
"_score": 3.1396344,
"_source": {
"MDMGlobalData": {
"name": "Sony"
}
}
},
{
"_index": "foo1",
"_type": "_doc",
"_id": "1",
"_score": 3.114749,
"_source": {
"MDMGlobalData": {
"name": "Sony Music"
}
}
},
{
"_index": "foo1",
"_type": "_doc",
"_id": "2",
"_score": 3.097392,
"_source": {
"MDMGlobalData": {
"name": "Sony Music Corp"
}
}
},
{
"_index": "foo1",
"_type": "_doc",
"_id": "3",
"_score": 3.084596,
"_source": {
"MDMGlobalData": {
"name": "All Sony Music Corp"
}
}
}
]
As you can see the order is still maintained, Sony is having maximum score (as it should be according to the query taken) and then further scoring is done on the basis of the order of the OR clauses.