Elasticsearch不存储值是什么意思?

cxfofazt  于 2022-11-22  发布在  ElasticSearch
关注(0)|答案(1)|浏览(114)

这是text类型的store选项的Elasticsearch文档的一部分:
默认情况下,会对字段值进行索引以使其可搜索,但不会存储字段值。这意味着可以查询字段,但无法检索原始字段值。
我不明白什么是 * 字段默认不存储 *,这怎么可能呢?我肯定我在这里遗漏了什么,谁能用通俗的英语给我解释一下?
link

7fyelxc5

7fyelxc51#

让我们假设,如果您想将hello world in Elasticsearch存储在title中,并想在搜索结果中找到它,当您在标题中使用任何单词进行搜索时,例如:helloworldElasticsearch ..那么你需要在ElasticSearch倒排索引中有这些搜索词的标记。
默认情况下,所有Elasticsearch文本字段都要经过text analysis(为输入文本创建标记(纯英语世界))。
在我们的示例中,给定的标题将生成以下标记,您还可以使用以下API验证自己

GET http://es:9200/_analyze

{
    "text" : "hello world in Elasticsearch",
    "analyzer": "standard"
}

和结果令牌

{
    "tokens": [
        {
            "token": "hello",
            "start_offset": 0,
            "end_offset": 5,
            "type": "<ALPHANUM>",
            "position": 0
        },
        {
            "token": "world",
            "start_offset": 6,
            "end_offset": 11,
            "type": "<ALPHANUM>",
            "position": 1
        },
        {
            "token": "in",
            "start_offset": 12,
            "end_offset": 14,
            "type": "<ALPHANUM>",
            "position": 2
        },
        {
            "token": "elasticsearch",
            "start_offset": 15,
            "end_offset": 28,
            "type": "<ALPHANUM>",
            "position": 3
        }
    ]
}

现在存储意味着一个字段的完整字符串aka(未标记)hello world in Elasticsearch,它对全文搜索没有用处,如Elasticsearch文章中所解释的,默认存储****作为_source的一部分。
希望这对你有帮助。

相关问题