【问题标题】:Elasticsearch copy_to field typeElasticsearch copy_to 字段类型
【发布时间】:2021-01-06 07:17:28
【问题描述】:

我想知道copy_to的目标字段类型是否必须是text类型。 我在官方文档中没有找到描述。 https://www.elastic.co/guide/en/elasticsearch/reference/current/copy-to.html

也就是说,full_name的类型可以是其他类型而不是文本吗?谢谢。

PUT my-index-000001
{
  "mappings": {
    "properties": {
      "first_name": {
        "type": "text",
        "copy_to": "full_name" 
      },
      "last_name": {
        "type": "text",
        "copy_to": "full_name" 
      },
      "full_name": {
        "type": "text"
      }
    }
  }
}

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    您可以自己尝试一下,我尝试使用 keywordinteger 类型创建它,效果非常好。

    但是,如果您将其定义为整数,然后尝试像示例中给出的那样对文本进行索引,它将抛出 mapper_parsing_exception

    【讨论】:

    • 非常感谢您的回复。在问这个问题之前,我实际上自己尝试过。我发现当new_full_name的类型指定为keyword时,可以成功创建索引,但是没有返回任何结果。那么,我想知道只有文本类型运行良好吗?
    • ``` PUT /copy_to_idx { "mappings":{ "properties": { "new_first_name": { "type": "text", "copy_to": "new_full_name" }, "new_last_name" : { "type": "text", "copy_to": "new_full_name" }, "new_full_name": { "type": "keyword" }}} } POST _bulk { "create" : { "_index" : "copy_to_idx" , "_id" : "1" } } { "new_first_name" : "Peter", "new_last_name" : "Smith" } GET copy_to_idx/_search { "query": { "match": { "new_full_name": "Peter Smith" } } } ```
    • 对不起格式丑陋,这是我尝试的链接:github.com/ZhangDi-d/elasticsearch-demo/blob/main/copy_to.md
    • @xuelai,很抱歉回复延迟,我查看了您的 github 链接,这让我明白了,但是您没有得到结果的原因是因为您使用了关键字字段存储 PeterSmith 但如果您只尝试使用单个字段 first namePeter,它将显示结果。这意味着它可以工作
    • @Ninja 谢谢,我会多花点时间考虑的,谢谢。
    猜你喜欢
    • 2021-12-26
    • 1970-01-01
    • 2018-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-05
    • 2018-07-21
    • 1970-01-01
    相关资源
    最近更新 更多