gpt4 book ai didi

Elasticsearch:查询差异中的通配符: "Alex*"与 "*lex*"

转载 作者:行者123 更新时间:2023-11-29 02:55:19 26 4
gpt4 key购买 nike

我有一堆使用关键字分词器索引的数据。

{
state: open
settings: {
index.number_of_replicas: 0
index.analysis.analyzer.default.type: keyword
index.number_of_shards: 5
index.version.created: 900599
}
mappings: {
evenements: {
properties: {
prenom: {
type: string
}
nom: {
type: string
}
statut: {
type: string
}
fieldDate: {
format: dateOptionalTime
type: date
}
}
}
}
}

查询时

{
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "evenements.prenom",
"query": "*lex*"
}
}
]
}
}
}

我得到了结果,但是在查询的时候

{
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "evenements.prenom",
"query": "Alex*"
}
}
]
}
}
}

我没有得到任何结果(A ou a 而不是 first * 不会改变任何东西)。

有什么解释吗?

谢谢。颜

最佳答案

尝试将查询字符串的 lowercase_expanded_terms 属性设置为 false。默认情况下,此属性设置为 true 并可能导致您所拥有的行为。

{
"query": {
"bool": {
"must": [
{
"query_string": {
"lowercase_expanded_terms": false,
"default_field": "evenements.prenom",
"query": "Alex*"
}
}
]
}
}
}

关于Elasticsearch:查询差异中的通配符: "Alex*"与 "*lex*",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19220424/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com