Hi guys,
I guess, this is pretty trivial question, but so far I couldn't find the
answer.
The case: I have 4+ indices which contain different type of data (properly
mapped of this make sense). I need to execute a search across all indices
for a term, but when I search I need to put some weight over some of the
fields such as "name" should have higher weight than "address" or
"description".
Here is a concrete example:
Index: venues which has name (weight 4), address (weight 3) all other
fields (weight 2)
Index: users which has name (weight 4), address (weight 3) all other fields
(weight 2)
Index: event (which belongs to venue) which has name (weight 4), venue_name
(weight 3), address (weight 2) all other fields (weight 1)
So, I need to search for term or phrase like "John" which should search
within these indices and sort the results by the score. (there could be
user with First name "John", bar "Long John" or "event johns' bar event",
address containing John or even description which is in "all other fields".
To do so, I've read that I should use bool query together with multi match,
but there is also DIS max query and I don't know how to specify the index.
Here is what I am thinking to do so far:
curl -XGET 'http://localhost:9200/_search?pretty=true' -d '
{
"query" : {
"should" : [
{
"multi_match" : {
"query" : "John",
"fields" : ["name^4", "address^3"],
//somehow I need to specify that this is for index
venues
}
},
{
"multi_match" : {
"query" : "John",
"fields" : ["name^4", "address^3"],
//somehow I need to specify that this is for index users
}
},
{
"multi_match" : {
"query" : "John",
"fields" : ["name^4", "parent_name^3, "address^2"],
//somehow I need to specify that this is for index
events
}
}
]
}
}'
Again sorry for the trivial question.
Best regards and Merry Christmas!
Nik
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/9a2645dd-def2-41f6-80a8-ecda1946e998%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.