My Elasticserch index Index Name = movies
{
"title": "Chris ENDGAME",
"cast": [
{
"firstName": "Chris",
"lastName": "Evans"
},
{
"firstName": "Chris",
"lastName": "Hemsworth"
},
{
"firstName": "Chris",
"lastName": "Prat"
}
]
}
Similarly, I have 3 more movie documents
Movies2: Winter Soldier
cast: Chris Evans, Scarlett Johanson
Movies3: Ant-Man
cast: Paul Rudd, Michael Pena
Movies4: Avengers
cast: Chris Evans, Chris Hemsworth
With this, now I have 4 movies: 1. Endgame; 2.Winter Soldier; 3.Ant-Man; 4.Avengers
Now, I want to create an elasticsearch7 search query where if I search Chris' (overall: both title and first name) in an order of the number of matches per index searched.
i.e., OUTPUT(ordered) = Movies1,Movies4,Movies2, because movie1 has 4 , Movies4 has 2 and Movies2 has 1 chris matching in firstname
Till now, I have been able to write a basic query but I have no idea how to order the documents
My Search Query
{
"query": {
"bool": {
"must": [
{ "multi_match": { "query": "Chris" }}
]
}
}
}
How do I order it?