java多表多字段的模糊匹配_Elasticsearch多字段模糊搜索首先不返回精确匹配

博主在Elasticsearch中遇到一个模糊搜索问题,当对'text'和'keywords'字段进行模糊查询时,发现完全匹配的文档与部分匹配的文档得分相同。查询使用了fuzzy查询,并设定了min_similarity、prefix_length和boost参数。尽管查询结果中展示了两个文档,它们的分数相同,但期望完全匹配的文档得分更高。问题可能与使用的'uax_url_email'标记器和'小写'过滤器有关。
摘要由CSDN通过智能技术生成

我正在对'text'和'keywords'字段执行模糊弹性搜索查询 . 我在elasticsearch中有两个文档,一个是“text”“testPhone 5”,另一个是“testPhone 4s” . 当我使用“testPhone 5”执行模糊查询时,我发现两个文档都被赋予了完全相同的分数值 . 为什么会这样?

额外信息:我使用'uax_url_email'标记器和'小写'过滤器索引文档 .

这是我正在进行的查询:

{

query : {

bool: {

// match one or the other fuzzy query

should: [

{

fuzzy: {

text: {

min_similarity: 0.4,

value: 'testphone 5',

prefix_length: 0,

boost: 5,

}

}

},

{

fuzzy: {

keywords: {

min_similarity: 0.4,

value: 'testphone 5',

prefix_length: 0,

boost: 1,

}

}

}

]

}

},

sort: [

'_score'

],

explain: true

}

这是结果:

{ max_score: 0.47213298,

total: 2,

hits:

[ { _index: 'test',

_shard: 0,

_id: '51fbf95f82e89ae8c300002c',

_node: '0Mtfzbe1RDinU71Ordx-Ag',

_source:

{ next: { id: '51fbf95f82e89ae8c3000027' },

cards: [ '51fbf95f82e89ae8c3000027', [length]: 1 ],

other: false,

_id: '51fbf95f82e89ae8c300002c',

category: '51fbf95f82e89ae8c300002b',

image: 'https://s3.amazonaws.com/sold_category_icons/Smartphones.png',

text: 'testPhone 5',

keywords: [ [length]: 0 ],

__v: 0 },

_type: 'productgroup',

_explanation:

{ details:

[ { details:

[ { details:

[ { details:

[ { details:

[ { value: 3.8888888, description: 'boost' },

{ value: 1.5108256,

description: 'idf(docFreq=2, maxDocs=5)' },

{ value: 0.17020021,

description: 'queryNorm' },

[length]: 3 ],

value: 0.99999994,

description: 'queryWeight, product of:' },

{ details:

[ { details:

[ { value: 1, description: 'termFreq=1.0' },

[length]: 1 ],

value: 1,

description: 'tf(freq=1.0), with freq of:' },

{ value: 1.5108256,

description: 'idf(docFreq=2, maxDocs=5)' },

{ value: 0.625,

description: 'fieldNorm(doc=0)' },

[length]: 3 ],

value: 0.944266,

description: 'fieldWeight in 0, product of:' },

[length]: 2 ],

value: 0.94426596,

description: 'score(doc=0,freq=1.0 = termFreq=1.0\n), product of:' },

[length]: 1 ],

value: 0.94426596,

description: 'weight(text:testphone^3.8888888 in 0) [PerFieldSimilarity], result of:' },

[length]: 1 ],

value: 0.94426596,

description: 'sum of:' },

{ value: 0.5, description: 'coord(1/2)' },

[length]: 2 ],

value: 0.47213298,

description: 'product of:' },

_score: 0.47213298 },

{ _index: 'test',

_shard: 4,

_id: '51fbf95f82e89ae8c300002d',

_node: '0Mtfzbe1RDinU71Ordx-Ag',

_source:

{ next: { id: '51fbf95f82e89ae8c3000027' },

cards: [ '51fbf95f82e89ae8c3000029', [length]: 1 ],

other: false,

_id: '51fbf95f82e89ae8c300002d',

category: '51fbf95f82e89ae8c300002b',

image: 'https://s3.amazonaws.com/sold_category_icons/Smartphones.png',

text: 'testPhone 4s',

keywords: [ 'apple', [length]: 1 ],

__v: 0 },

_type: 'productgroup',

_explanation:

{ details:

[ { details:

[ { details:

[ { details:

[ { details:

[ { value: 3.8888888, description: 'boost' },

{ value: 1.5108256,

description: 'idf(docFreq=2, maxDocs=5)' },

{ value: 0.17020021,

description: 'queryNorm' },

[length]: 3 ],

value: 0.99999994,

description: 'queryWeight, product of:' },

{ details:

[ { details:

[ { value: 1, description: 'termFreq=1.0' },

[length]: 1 ],

value: 1,

description: 'tf(freq=1.0), with freq of:' },

{ value: 1.5108256,

description: 'idf(docFreq=2, maxDocs=5)' },

{ value: 0.625,

description: 'fieldNorm(doc=0)' },

[length]: 3 ],

value: 0.944266,

description: 'fieldWeight in 0, product of:' },

[length]: 2 ],

value: 0.94426596,

description: 'score(doc=0,freq=1.0 = termFreq=1.0\n), product of:' },

[length]: 1 ],

value: 0.94426596,

description: 'weight(text:testphone^3.8888888 in 0) [PerFieldSimilarity], result of:' },

[length]: 1 ],

value: 0.94426596,

description: 'sum of:' },

{ value: 0.5, description: 'coord(1/2)' },

[length]: 2 ],

value: 0.47213298,

description: 'product of:' },

_score: 0.47213298 },

[length]: 2 ] }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值