Elasticsearch中没有基本查询的结果

cclgggtu  于 2022-12-03  发布在  ElasticSearch
关注(0)|答案(1)|浏览(142)

我尝试在本地建立一个基本的Elasticsearch索引,并使用Kibana,当我进行match_all搜索时,我能够得到所有结果,但我尝试了许多简单匹配查询的变体,但都不起作用。
我的Map:

{
  "recipes-v1": {
    "mappings": {
      "dynamic": "false",
      "properties": {
        "description": {
          "type": "keyword"
        },
        "ingredients": {
          "type": "text"
        },
        "instructions": {
          "type": "keyword"
        },
        "title": {
          "type": "keyword"
        }
      }
    }
  }
}

match_all查询的结果:

{
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 2,
      "relation": "eq"
    },
    "max_score": 1,
    "hits": [
      {
        "_index": "recipes-v1",
        "_id": "0",
        "_score": 1,
        "_source": {
          "Name": "Alfredo Sauce",
          "Description": "Cheesy alfredo sauce that is delicious. Definitely not vegan",
          "Ingredients": [
            "1/2 cup butter",
            "3 cloves garlic"
          ],
          "Instructions": [
            "Melt butter in a saucepan then add heavy cream and combine on medium low heat",
            "Let the mixture simmer for 2 minutes then add garlic, salt, pepper, and italian seasoning to taste. Let simmer until fragrent (about 1 minute)"
          ]
        }
      },
      {
        "_index": "recipes-v1",
        "_id": "1",
        "_score": 1,
        "_source": {
          "Name": "Shrimp Scampi",
          "Description": "Definitely not just Gordon Ramsay's shrimp scampi minus capers",
          "Ingredients": [
            "1 lb shrimp",
            "2 lemons"
          ],
          "Instructions": [
            "Do things",
            "Do more things"
          ]
        }
      }
    ]
  }
}

我试过删除索引并重新创建它,以及Alfredo,alfredo,alfredo酱料,AlfredoSauce等的每一个变体,但都没有成功。请帮助这些查询中的所有变体都没有命中:
第一次

**EDIT/UPDATE:**我将文档字段全部更改为小写,但问题仍然存在。但是,如果我使用新索引将动态Map设置为True,则一切都正常。Map现在是这样的,并且正常工作,但我仍然想知道为什么静态Map不工作,因为最终我会将其设置为静态的。

{
  "recipes-v1": {
    "mappings": {
      "properties": {
        "description": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "ingredients": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "instructions": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "name": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        }
      }
    }
  }
}
balp4ylt

balp4ylt1#

您的文档包含大写的字段名称,例如DescriptionIngredients
您的Map包含相同的字段名称,但使用小写字母,例如descriptioningredients等,并且已禁用动态Map(dynamic: false),因此将不会动态创建新字段并为其编制索引。
您需要更改Map或文档,以便两者具有完全相同的字段名称

相关问题