zoukankan      html  css  js  c++  java
  • elasticsearch _source字段的一些说明

    _source field

    The _source field contains the original JSON document body that was passed at index time. The_source field itself is not indexed (and thus is not searchable), but it is stored so that it can be returned when executing fetch requests, like get or search.

    Disabling the _source field

    Though very handy to have around, the source field does incur storage overhead within the index. For this reason, it can be disabled as follows:

    PUT tweets
    {
      "mappings": {
        "tweet": {
          "_source": {
            "enabled": false
          }
        }
      }
    }
    Warning

    Think before disabling the _source field

    Users often disable the _source field without thinking about the consequences, and then live to regret it. If the _source field isn’t available then a number of features are not supported:

    • The updateupdate_by_query, and reindex APIs.
    • On the fly highlighting.
    • The ability to reindex from one Elasticsearch index to another, either to change mappings or analysis, or to upgrade an index to a new major version.
    • The ability to debug queries or aggregations by viewing the original document used at index time.
    • Potentially in the future, the ability to repair index corruption automatically.
    Tip

    If disk space is a concern, rather increase the compression level instead of disabling the _source.

    Including / Excluding fields from _source

    An expert-only feature is the ability to prune the contents of the _source field after the document has been indexed, but before the _source field is stored.

    Warning

    Removing fields from the _source has similar downsides to disabling _source, especially the fact that you cannot reindex documents from one Elasticsearch index to another. Consider using source filtering instead.

    The includes/excludes parameters (which also accept wildcards) can be used as follows:

    PUT logs
    {
      "mappings": {
        "event": {
          "_source": {
            "includes": [
              "*.count",
              "meta.*"
            ],
            "excludes": [
              "meta.description",
              "meta.other.*"
            ]
          }
        }
      }
    }
    
    PUT logs/event/1
    {
      "requests": {
        "count": 10,
        "foo": "bar" 
      },
      "meta": {
        "name": "Some metric",
        "description": "Some metric description", 
        "other": {
          "foo": "one", 
          "baz": "two" 
        }
      }
    }
    
    GET logs/event/_search
    {
      "query": {
        "match": {
          "meta.other.foo": "one" 
        }
      }
    }

       

    These fields will be removed from the stored _source field.

    We can still search on this field, even though it is not in the stored _source.

  • 相关阅读:
    java并发编程(五)——线程池
    java并发编程(四)——无锁
    java并发编程(三)——java内存模型
    java并发编程(二)——加锁
    java并发编程(一)——进程与线程
    java中的异常和处理机制
    使用JDK自带的keytool工具生成证书
    JAVA 制作证书
    网络安全之证书相关概念
    maven之.lastUpdated文件
  • 原文地址:https://www.cnblogs.com/bonelee/p/6439120.html
Copyright © 2011-2022 走看看