Hello,
I am relatively new to Elasticsearch. I do understand the basic concepts
but have trouble with more advanced queries.
I am trying to build a query which searches by several keywords on 2
fields: 'title' and 'description' where matches for 'title' are boosted.
Then I need to boost results which have phrase matches so that they appear
first after sorting. (Also, 'title' and 'description' fields are
multi-fields).
For instance, if searching for "hard drive enclosure" I would find a number
of records which have these words in the title and description. But then
the question is how to boost documents which contain phrases "hard drive
enclosure", "hard drive" or "drive enclosure".
The following query works well for the first part of the requirement:
{"size":"40","sort":{"_score":""},"query":
{ "multi_match" : {
"query" : "hard drive enclosure",
"fields" : [ "title^2", "description" ]
}
}}
But how to boost phrase matches still remains up to debate. I believe, I
should be able to construct a boolean 'should' query which combines the
existing query with 'match_phrase' query. However, it seems like this may
create performance issue (now more than one query has to run simultaneously
while it's just a matter of going through result set and manipulating boost
value).
Another way of accomplishing this would be using custom boost with
scripting. I looked at this but can't figure out for the life of me how to
find a substring of a string with MVEL. Started looking at Javascript
plugin for this.
So, what would be the recommended way of creating this query?
All suggestions are appreciated.
Vic
Relevant parts of the mapping are as follows:
{
"number_of_shards" : 1,
"index" : {
"analysis":{
"filter":{
"name_ngrams":{
"side":"front",
"max_gram":8,
"min_gram":3,
"type":"edgeNGram"
}
},
"analyzer":{
"full_name":{
"filter":[
"standard",
"lowercase",
"asciifolding"
],
"type":"custom",
"tokenizer":"standard"
},
"partial_name":{
"filter":[
"standard",
"lowercase",
"asciifolding",
"name_ngrams"
],
"type":"custom",
"tokenizer":"standard"
}
}
}
}
};
"title": { "fields":{
"title":{
"type":"string",
"analyzer":"full_name"
},
"title_partial":{
"search_analyzer":"full_name",
"index_analyzer":"partial_name",
"type":"string"
}
},
"type":"multi_field"
},
"description": { "fields":{
"description":{
"type":"string",
"analyzer":"full_name"
},
"description_partial":{
"search_analyzer":"full_name",
"index_analyzer":"partial_name",
"type":"string"
}
},
"type":"multi_field"
},
--
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.
For more options, visit https://groups.google.com/groups/opt_out.