摘要1:https://www.elastic.co/guide/cn/elasticsearch/guide/current/mapping-intro.html
摘要2:es中的ignore_above参数:https://www.jianshu.com/p/133a0f49311a
默认, string
类型域会被认为包含全文。就是说,它们的值在索引前,会通过一个分析器,针对于这个域的查询在搜索前也会经过一个分析器。
string
域映射的两个最重要属性是 index
和 analyzer
。
index
属性控制怎样索引字符串。它可以是下面三个值:
analyzed
- 首先分析字符串,然后索引它。换句话说,以全文索引这个域。
not_analyzed
- 索引这个域,所以它能够被搜索,但索引的是精确值。不会对它进行分析。
no
- 不索引这个域。这个域不会被搜索到。
string
域 index
属性默认是 analyzed
。如果我们想映射这个字段为一个精确值,我们需要设置它为 not_analyzed
:
{
"tag": {
"type": "string",
"index": "not_analyzed"
}
}
注意:
其他简单类型(例如 long
, double
, date
等)也接受 index
参数,但有意义的值只有 no
和 not_analyzed
, 因为它们永远不会被分析。