Below is the sample data in elasticsearch
PUT /data/test/1
{
"id": "Accounting 101",
"room": "E3",
"professor": {
"name": "Thomas Baszo",
"email": "baszot@onuni.com"
},
"students_enrolled": 27,
"course_description": " financial statements"
}
PUT /data/test/2
{
"name": "Accounting 101",
"room": "E3",
"professor": {
"name": "Sachin Baszo",
"email": "baszot@onuni.com"
},
"students_enrolled": 27,
"course_description": "Thomas Thomas Thomas Thomas "
}
Below is the query
GET /_search
{
"query": {
"query_string": {
"query": "(*Thomas*)"
}
}
}
My output will show second document as first as it contains "Thomas" 4 times in the description
- I need to give more weightage to
professor.nameit should show first check if not then check "professor.email" then check other attributes
Python
es.search(index="data", body={"query": {"query_string": {"query": "(*Thomas*)"}}})