ElasticSearch 映射不可搜索字段

Edw*_*den 3 php python lucene indexing elasticsearch

我是弹性搜索新手。

在我的索引users类型中profiles,我有字段

properties : {
    name : {type : string},
    picture : {
                  url_small : {}
                  url_big : {}   
         } 
}
Run Code Online (Sandbox Code Playgroud)

此索引picture仅用于存储/获取数据,永远不会用于执行任何查询,而只会通过匹配的命中进行检索。

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

Pan*_*wan 5

概念:

您在这里处理两件事:

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

要定义数据的存储方式,您可以使用type.

要定义数据的索引方式(在分析后直接索引,或者在您的情况下不索引),您可以使用index.

如果您想定义如何分析数据以建立索引,则必须使用analyzer.

在你的情况下:

您想要存储字符串,但不想对它们进行索引,因此您使用:

{
    type: string,
    index: no
}
Run Code Online (Sandbox Code Playgroud)

这给你:

properties : {
    name : {"type": "string"},
    picture : {
        url_small : {
            "type": "string",
            "index": "no"
        },
        url_big : {
            "type": "string",
            "index": "no"
        }   
    } 
}
Run Code Online (Sandbox Code Playgroud)

有关索引字段的更多信息,请参见此处:

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

希望清楚