通配符和定期搜索根据情况返回不同的结果

发布于 2025-01-26 01:39:47 字数 1088 浏览 1 评论 0原文

我正在使用Docker Image使用OpenSearch版本1.3.1。

这是我的索引和一个文档:

PUT index_0
{
   "settings":{
      "analysis":{
         "analyzer":{
            "keyword_lower":{
               "type":"custom",
               "tokenizer":"keyword",
               "filter":"lowercase"
            }
         }
      }
   },
   "mappings":{
      "properties":{
         "id":{
            "type":"text",
            "index":true
         },
         "name":{
            "type":"text",
            "index":true,
            "analyzer":"keyword_lower"
         }
      }
   }
}

PUT index_0/_doc/1
{
  "id":"123",
  "name":"FooBar"
}

如果我运行此查询,我会得到结果(请注意,请注意较小的b):

GET index_0/_search?pretty
{"query":{"wildcard":{"name":"Foobar"}}}

但是,如果我运行此查询,则不会:

GET index_0/_search?pretty
{"query":{"term":{"name":"Foobar"}}}

为什么A term term为什么搜索似乎是案例敏感的,而Wildcard却不是相同的字段?

I am using OpenSearch version 1.3.1 via the Docker image.

Here is my index and a document:

PUT index_0
{
   "settings":{
      "analysis":{
         "analyzer":{
            "keyword_lower":{
               "type":"custom",
               "tokenizer":"keyword",
               "filter":"lowercase"
            }
         }
      }
   },
   "mappings":{
      "properties":{
         "id":{
            "type":"text",
            "index":true
         },
         "name":{
            "type":"text",
            "index":true,
            "analyzer":"keyword_lower"
         }
      }
   }
}

PUT index_0/_doc/1
{
  "id":"123",
  "name":"FooBar"
}

If I run this query, I get results (notice the difference in case, lowercase b):

GET index_0/_search?pretty
{"query":{"wildcard":{"name":"Foobar"}}}

But if I run this query, I do not:

GET index_0/_search?pretty
{"query":{"term":{"name":"Foobar"}}}

Why does a term search seem to be case sensitive whereas a wildcard one is not, given the same field?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文