我想在弹性搜索中使用通配符搜索数组值
{
"query": {
"wildcard": {
"short_message": {
"value": "*nne*",
"boost": 1.0,
"rewrite": "constant_score"
}
}
}
}
我正在搜索“短消息”,它对我有用。 但我想搜索“messages.message”,它不起作用
{
"query": {
"wildcard": {
"messages.message": {
"value": "*nne*",
"boost": 1.0,
"rewrite": "constant_score"
}
}
}
}
我还想搜索数组中的多个字段
例如:- 字段:[“messages.message”、“messages.subject”、“messages.email\u search”]
那就有可能给我最好的解决方案
提前谢谢
似乎您正在为} 数据类型
messages
使用^{为此,您需要使用^{} :
对于多字段查询,您可能可以使用
query_string
进行查询,因此基本上您的解决方案是在nested query
中使用query_string
查询字符串:
查询DSL
您也可以使用
wildcard
使用Query DSL
使用wildcard
,但同样,您需要为每个字段添加多个查询子句,出于性能原因,我怀疑通配符查询不支持多字段查询请注意,通配符搜索是不可取的,因为它必须执行大量的正则表达式操作,并且会影响获得响应的延迟。相反,我建议您查看Ngram Tokenizer,这样您就可以使用简单的匹配查询来获得所需的结果
让我知道这是否有帮助
相关问题 更多 >
编程相关推荐