作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
带有cross_fiels
类型和同义词的Elasticsearch多匹配查询无法正常工作。
我有以下配置:
{
"my_index": {
"mappings": {
"my_mapping": {
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"field1": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"field2": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
},
"settings": {
"index": {
"analysis": {
"filter": {
"my_synonym_filter": {
"type": "synonym",
"synonyms": [
"matthew,matt,matty",
"thomas,tom,thom,tommy"
]
}
},
"analyzer": {
"my_synonyms": {
"filter": [
"lowercase",
"my_synonym_filter"
],
"tokenizer": "standard"
}
}
}
}
}
}
}
{
"query":{
"bool":{
"should":[
{
"multi_match":{
"fields":[
"field1^8",
"field2^2"
],
"query":"Matt And Tom Oldfield",
"type":"cross_fields",
"analyzer": "my_synonyms"
}
}
]
}
}
}
(Synonym(field1:matt field1:matthew field1:matty) blended(terms:[field1:and^8.0, field2:and^2.0]) Synonym(field1:thom field1:thomas field1:tom field1:tommy) blended(terms:[field1:oldfield^8.0, field2:oldfield^2.0]))
field1
),而没有扩展其他字段。
(blended(terms:[field1:matt^8.0, field2:matt^2.0]) blended(terms:[field1:and^8.0, field2:and^2.0]) blended(terms:[field1:tom^8.0, field2:tom^2.0]) blended(terms:[field1:oldfield^8.0, field2:oldfield^2.0]))
最佳答案
我无法在 flex 5.5.0的环境中重现您的问题。
这是我的MVCE设置:
{
"settings": {
"index": {
"analysis": {
"filter": {
"my_synonym_filter": {
"type": "synonym",
"synonyms": [
"matthew,matt,matty",
"thomas,tom,thom,tommy"
]
}
},
"analyzer": {
"my_synonyms": {
"filter": [
"lowercase",
"my_synonym_filter"
],
"tokenizer": "standard"
}
}
}
}
},
"mappings": {
"my_mapping": {
"properties": {
"field1": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"field2": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
{ "field1": "Tom Oldfield", "field2": "Matt Oldfield"}
((field1:matt)^8.0 | (field1:matthew)^8.0 | (field1:matty)^8.0 | (field2:matt)^2.0 | (field2:matthew)^2.0 | (field2:matty)^2.0)
((field1:and)^8.0 | (field2:and)^2.0)
((field1:tom)^8.0 | (field1:thomas)^8.0 | (field1:thom)^8.0 | (field1:tommy)^8.0 | (field2:tom)^2.0 | (field2:thomas)^2.0 | (field2:thom)^2.0 | (field2:tommy)^2.0)
((field1:oldfield)^8.0 | (field2:oldfield)^2.0))
关于elasticsearch - Elasticsearch multi_match查询不适用于同义词和cross_fields,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45148041/
我有代表用户的文档。它们有字段 name 和 surname。 假设我有两个用户编入索引 - Michael Jackson 和 Michael Starr。我希望这些示例搜索有效: Michael
我正在尝试使用类型设置为 cross_fields 的 elasticsearch(版本 1.0)多匹配查询,就像 elasticsearch 页面 here 上的手册一样: 查询看起来像这样(和 e
我有一个类型为 cross_fields 的 multi_match 查询,我想通过前缀匹配对其进行改进。 { "index": "companies", "size": 25, "fro
我是一名优秀的程序员,十分优秀!