gpt4 book ai didi

indexing - Elasticsearch:将映射字段类型ID从长整数更新为字符串

转载 作者:行者123 更新时间:2023-12-02 22:32:51 24 4
gpt4 key购买 nike

我从以下更改了elasticsearch映射字段类型:

    "articles": {
"properties": {
"id": {
"type": "long"
}}}


     "articles": {
"properties": {
"id": {
"type": "string",
"index": "not_analyzed"
}

之后,我执行了以下步骤:
  • 使用新映射创建索引
  • 将映射重新索引到新索引

  • 映射更新后,我以前的查询过滤器不再起作用,并且我没有结果:
    GET /art/_search
    {
    "query": {
    "filtered": {
    "query": {
    "match_all": {}
    },
    "filter": {
    "bool": {
    "must": [
    {
    "type": {
    "value": "articles"
    }
    },
    {
    "term": {
    "id": "123467679"
    }
    }
    ]
    }
    }
    }
    },
    "size": 1,
    "sort": [
    {
    "_score": "desc"
    }
    ]
    }

    如果我检查此查询,结果将是我期望的:
    GET /art/articles/_search
    {
    "query": {
    "match_all": {}
    }
    }

    如果有人对字段类型更改后的查询为什么不再起作用,我将不胜感激。

    谢谢!

    最佳答案

    查询中的问题与ID过滤器有关。
    该查询正常工作,将过滤器更改为:

    "term": {
    "id": "123467679"
    }

    在:
    "term": {
    "_id": "123467679"
    }

    我仍然是Elasticsearch的初学者,以弄清楚为什么虽然我进行了重新索引,但映射更改为何导致查询中断,但是“_id”修复了我的查询。

    您可以在以下位置找到更多信息:
    elasticsearch mapping reference documentation

    关于indexing - Elasticsearch:将映射字段类型ID从长整数更新为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29799281/

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