Elasticsearch cross_字段所有术语必须至少出现在on字段中
我想构建一个Elasticsearch查询,其中我查询多个字段,所有字段必须至少出现在一个字段中。我使用Elasticsearch cross_字段所有术语必须至少出现在on字段中,search,
elasticsearch,full-text-search,Search,
elasticsearch,Full Text Search,我想构建一个Elasticsearch查询,其中我查询多个字段,所有字段必须至少出现在一个字段中。我使用multi\u match查询cross\u字段 例如: 我的搜索是在用户对象上进行的,如: { firstname: '...', lastname: '...', email: '...' } 我们有2个用户: { firstname: 'Delphine', lastname: 'Dorémi', email: 'tyrell@interne.fr' } { firs
multi\u match
查询cross\u字段
例如:
我的搜索是在用户对象上进行的,如:
{ firstname: '...', lastname: '...', email: '...' }
我们有2个用户:
{
firstname: 'Delphine',
lastname: 'Dorémi',
email: 'tyrell@interne.fr'
}
{
firstname: 'Philippe',
lastname: 'Mifasol',
email: 'roybatty@interne.com'
}
询问:“雷切尔·米法索”
我想要的结果:没有结果(因为“Philippe”用户对象中缺少“Rachel”)
Elasticsearch实际给我的结果是:“Philippe”(我想是因为“Mifasol”匹配…)
这里是我的Elasticsearch查询:
query: {
multi_match: {
query: 'Rachel Mifasol',
type: 'cross_fields',
fields: ['firstname', 'lastname', 'emails'],
operator: 'and'
}
}
这里是我的分析器和映射:
settings: {
analysis: {
filter: {
nGram_filter: {
type: 'nGram',
min_gram: 2,
max_gram: 20,
token_chars: [
'letter',
'digit',
'punctuation',
'symbol'
]
}
},
analyzer: {
nGram_analyzer: {
type: 'custom',
tokenizer: 'whitespace',
filter: [
'lowercase',
'asciifolding',
'nGram_filter'
]
},
whitespace_analyzer: {
type: 'custom',
tokenizer: 'whitespace',
filter: [
'lowercase',
'asciifolding'
]
}
}
}
},
mappings: {
users: {
properties: {
firstname: {
type: 'string',
index_analyzer: 'nGram_analyzer',
search_analyzer: 'whitespace_analyzer',
fields: {
sort: {
type: 'string',
index: 'not_analyzed'
}
}
},
lastname: {
type: 'string',
index_analyzer: 'nGram_analyzer',
search_analyzer: 'whitespace_analyzer'
},
emails: {
type: 'string',
index_analyzer: 'nGram_analyzer',
search_analyzer: 'whitespace_analyzer'
}
}
}
}
你确定这个查询没有得到任何结果吗?我的应用程序执行这个查询(一个单词数组):查询:{multi_match:{query:['Rachel','Mifasol'],键入:'cross_fields',fields:['firstname','lastname','emails'],operator:'and'}这就是我得到结果的原因。。。所以我的问题是个错误。对不起,你明白了吗?我的问题是个错误。我发送给ES的查询是['Rachel','Mifasol',],而不是'Rachel Mifasol'。