【问题标题】:ElasticSearch Mapping Non Searchable FieldElasticSearch 映射不可搜索字段
【发布时间】:2017-05-25 11:13:05
【问题描述】:

我是弹性搜索的新手。

在我的users 中输入profiles 索引我有字段

properties : {
    name : {type : string},
    picture : {
                  url_small : {}
                  url_big : {}   
         } 
}

在此索引中,picture 仅用于存储/获取数据,并且将从不用于执行任何查询,而只会在匹配的匹配项中检索。

那么如何创建picture 的映射呢?我应该使用什么typeanalyzer、字段?

【问题讨论】:

  • 嗨,Edward,使用 index: no 和您想要的类型(string 如果 2.x,text 如果 5.x)
  • 图片是一个字符串数组 制作图片 {type : "string"} 可以吗?
  • 是的,您对字符串和字符串数组使用相同的映射(只要它不是关联数组)
  • 是的,它是一个 assoc 数组,类似于 ["picture"=>["url_small"="www.exe.com.jpg","url_big"=>"www.exs.com.jpg"] ]@Pandawan
  • 查看下面的答案,我对数组的评论是因为我认为你有["picture"=>["url_small"=["url1", "url2"], ...,在这种情况下,下面描述的映射仍然有效

标签: php python elasticsearch indexing lucene


【解决方案1】:

概念:

你在这里处理两件事:

  1. 数据将如何存储
  2. 如何索引数据

要定义数据的存储方式,请使用type

要定义数据将如何被索引(直接,在被分析之后,或者,在你的情况下,不被索引),你使用index

如果你想定义如何为索引分析数据,你必须使用analyzer

在你的情况下:

你想存储字符串,但不想索引它们,所以你使用:

{
    type: string,
    index: no
}

这给了你:

properties : {
    name : {"type": "string"},
    picture : {
        url_small : {
            "type": "string",
            "index": "no"
        },
        url_big : {
            "type": "string",
            "index": "no"
        }   
    } 
}

这里有关于索引字段的更多信息:

https://www.elastic.co/guide/en/elasticsearch/reference/2.4/mapping-index.html

希望清楚

【讨论】:

  • 当前 ES 版本 (7.13) 现在是 "index": "false"
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-31
  • 2017-11-06
  • 2019-02-05
相关资源
最近更新 更多