elasticsearch 如何在elasticsearch中为搜索查询添加模糊性?
我试图在跨字段查询中对特定字段实现模糊性。不过有点难 因此,查询应该:elasticsearch 如何在elasticsearch中为搜索查询添加模糊性?,elasticsearch,elasticsearch,我试图在跨字段查询中对特定字段实现模糊性。不过有点难 因此,查询应该: 跨字段匹配短语 与零件号和条形码精确匹配(无模糊性) 将模糊术语与标题和副标题进行匹配 我到目前为止的查询如下-注意到目前为止,模糊性在查询中根本不起作用 因此,这应该与1个结果相匹配,即标题中的“惊人t恤”,以及副标题中的蓝色。(注意拼写错误) 是否可以在索引映射级别实现模糊性?标题和副标题在数据集中很短,最多可能是30-40个字符 否则,如何在查询中为标题和副标题添加模糊性 { "query": { "mul
{
"query": {
"multi_match": {
"query": "Bleu Amazing T-Shirt",
"fuzziness": "auto",
"operator": "and",
"fields": [
"identity.partNumber^4",
"identity.altIdentifier^4",
"identity.barcode",
"identity.mpn",
"identity.ppn",
"descriptions.title",
"descriptions.subtitle"
],
"type": "cross_fields"
}
},
"fields": [
"identity.partNumber",
"identity.barcode",
"identity.ppn",
"descriptions.title",
"descriptions.subtitle"
]
}
似乎不支持使用交叉字段进行模糊搜索,但存在一些相关问题。因此,我在索引时将title和subtitle复制到一个新字段,而不是跨字段搜索,并按如下方式拆分查询。似乎至少对我的测试用例有效
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "{{searchTerm}}",
"operator": "and",
"fields": [
"identity.partNumber^4",
"identity.altIdentifier^4",
"identity.barcode",
"identity.mpn",
"identity.ppn"
],
"type": "best_fields"
}
},
{
"match": {
"fuzzyFields": {
"query": "{{searchTerm}}",
"operator": "and",
"fuzziness": "auto"
}
}
}
]
}
}
似乎不支持使用交叉字段进行模糊搜索,但存在一些相关问题。因此,我在索引时将title和subtitle复制到一个新字段,而不是跨字段搜索,并按如下方式拆分查询。似乎至少对我的测试用例有效
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "{{searchTerm}}",
"operator": "and",
"fields": [
"identity.partNumber^4",
"identity.altIdentifier^4",
"identity.barcode",
"identity.mpn",
"identity.ppn"
],
"type": "best_fields"
}
},
{
"match": {
"fuzzyFields": {
"query": "{{searchTerm}}",
"operator": "and",
"fuzziness": "auto"
}
}
}
]
}
}