I have a straight forward question where I have incorporated ngram's for partial matchings in 2.x. The implementation works well but the score results aren't working as I hoped. I would like my score results to look something like this:
Ke: .1
Kev: .2
Kevi: .3
Kevin: .4
Instead I am getting the following results where the scoring is the same if there is a match for the field:
Ke: .4
Kev: .4
Kevi: .4
Kevin: .4
Note: I originally asked this question on StackOverflow and the result was that changing from a ngram filter to a ngram tokenizer is a solution for version 1.7.x because it scores partial matches compounded. I am looking for a solution for ES 2.x. Thanks!
link: http://stackoverflow.com/questions/34618680/elasticsearch-scoring-with-ngrams/34625846#34625846
Settings:
settings: {
analysis: {
filter: {
ngram_filter: {
type: 'edge_ngram',
min_gram: 2,
max_gram: 15
}
},
analyzer: {
ngram_analyzer: {
type: 'custom',
tokenizer: 'standard',
filter: [
'lowercase',
'ngram_filter'
]
}
}
}
}
Mappings:
mappings: [{
name: 'voter',
_all: {
'type': 'string',
'analyzer': 'ngram_analyzer',
'search_analyzer': 'standard'
},
properties: {
last: {
type: 'string',
required : true,
include_in_all: true,
analyzer: 'ngram_analyzer',
search_analyzer: 'standard'
},
first: {
type: 'string',
required : true,
include_in_all: true,
analyzer: 'ngram_analyzer',
search_analyzer: 'standard'
},
}
}]
Query:
GET /user/_search
{
"query": {
"match": {
"_all": {
"query": "Ke",
"operator": "and"
}
}
}
}
In addition as a Part B question, when I add fuzziness to the query it increments partial matches scoring as I originally hoped but the exact match actually returns a lower score then partial match. Why is this?
GET /user/_search
{
"query": {
"match": {
"_all": {
"query": "Ke",
"operator": "and",
"fuzziness": 1
}
}
}
}
--Results--
Ke: 20584314
Kev: 0.25537512
Kevi: 0.26172742
Kevin: 0.21479698 <-- WHY?!