忽略 Elasticsearch 映射

救护车拉达

你好看起来映射对我不起作用,所以我试图删除索引并重新索引但总是得到相同的结果。以下是映射的外观和来自 GET 搜索端点的响应。因此 entry_id 字段被映射为整数,但作为字符串返回。

本地主机:9200/entries-vlatest/_mapping

{
    "entries-v1631182320": {
        "mappings": {
            "_doc": {
                "dynamic": "false",
                "properties": {
                    "entry_id": {
                        "type": "integer"
                    }
                }
            }
        }
    }
}

来自 get Search localhost:9200/entries-vlatest/_search 的响应

  "took": 4,
    "timed_out": false,
    "_shards": {
        "total": 2,
        "successful": 2,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": 1,
        "max_score": 1.0,
        "hits": [
            {
                "_index": "entries-v1631182320",
                "_type": "_doc",
                "_id": "15",
                "_score": 1.0,
                "_source": {
                    "entry_id": "15",
               
                }
            }
        ]
    }
}

所以我试图删除索引并重新索引

POST本地主机:9200/_reindex

    {
      "source": {
        "index": "entries-v1631182320"
      },
      "dest": {
        "index": "new_index"
      }
    }
Result:
    {
        "took": 257,
        "timed_out": false,
        "total": 1,
        "updated": 0,
        "created": 1,
        "deleted": 0,
        "batches": 1,
        "version_conflicts": 0,
        "noops": 0,
        "retries": {
            "bulk": 0,
            "search": 0
        },
        "throttled_millis": 0,
        "requests_per_second": -1.0,
        "throttled_until_millis": 0,
        "failures": []
    }

但是再次得到相同的结果,当我搜索重新索引的 GET localhost:9200/new_index/_search

{
    "took": 2,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": 1,
        "max_score": 1.0,
        "hits": [
            {
                "_index": "novi",
                "_type": "_doc",
                "_id": "15",
                "_score": 1.0,
                "_source": {
                    "entry_id": "15"
                   
                }
            }
        ]
    }
}

知道如何解决这个问题吗?

瓦尔

它工作正常。您将源文档entry_id作为字符串发送,Elasticsearch 不会修改该源文档,而是按原样存储它。

但是,该entry_id字段将按照映射中的描述进行索引和存储,即作为integer

如果您想“查看”一个整数,请将该值作为整数添加到源文档中。但最终它没有任何区别,即使您在文档中将其作为字符串发送,该值也将按照您的映射中指定的方式进行查看和处理,即作为整数。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章