gpt4 book ai didi

elasticsearch - elasticsearch不返回预期 yield

转载 作者:行者123 更新时间:2023-12-02 22:47:28 25 4
gpt4 key购买 nike

我是Elasticsearch的新手。我尝试了搜索API,但未返回预期的结果
我做了什么

POST /test/_doc/1
{
"name": "Hello World"
}

GET /test/_doc/1
Response:
{
"_index" : "test",
"_type" : "_doc",
"_id" : "1",
"_version" : 5,
"_seq_no" : 28,
"_primary_term" : 1,
"found" : true,
"_source" : {
"name" : "Hello World"
}
}

GET /test/_mapping
Response:
{
"test" : {
"mappings" : {
"properties" : {
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"query" : {
"properties" : {
"term" : {
"properties" : {
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
}
}
}

GET /test/_search
{
"query": {
"term": {
"name": "Hello"
}
}
}:
{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}

GET /test/_search
{
"query": {
"term": {
"name": "Hello World"
}
}
}
Response:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}
我的elasticsearch版本是7.3.2
最后两个搜索应该返回我文件1,对吗?为什么什么都没打?

最佳答案

问题是您有term queries。不分析词条查询。因此,Hello与索引中的hello术语不匹配。注意大小写差异。

Unlike full-text queries, term-level queries do not analyze search terms. Instead, term-level queries match the exact terms stored in a field.


Reference
match查询也会分析搜索词。
{
"query": {
"match": {
"name": "Hello"
}
}
}
您可以使用 _analyze来检查术语的索引方式。

关于elasticsearch - elasticsearch不返回预期 yield ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62768786/

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