"Fossies" - the Fresh Open Source Software Archive

Member "elasticsearch-6.8.23/docs/plugins/mapper-size.asciidoc" (29 Dec 2021, 1556 Bytes) of package /linux/www/elasticsearch-6.8.23-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming AsciiDoc format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

Mapper Size Plugin

The mapper-size plugin provides the _size meta field which, when enabled, indexes the size in bytes of the original {ref}/mapping-source-field.html[_source] field.

Installation

This plugin can be installed using the plugin manager:

sudo bin/elasticsearch-plugin install mapper-size

The plugin must be installed on every node in the cluster, and each node must be restarted after installation.

This plugin can be downloaded for offline install from {plugin_url}/mapper-size/mapper-size-{version}.zip.

Removal

The plugin can be removed with the following command:

sudo bin/elasticsearch-plugin remove mapper-size

The node must be stopped before removing the plugin.

Using the _size field

In order to enable the _size field, set the mapping as follows:

PUT my_index
{
  "mappings": {
    "_doc": {
      "_size": {
        "enabled": true
      }
    }
  }
}

The value of the _size field is accessible in queries, aggregations, scripts, and when sorting:

# Example documents
PUT my_index/_doc/1
{
  "text": "This is a document"
}

PUT my_index/_doc/2
{
  "text": "This is another document"
}

GET my_index/_search
{
  "query": {
    "range": {
      "_size": { (1)
        "gt": 10
      }
    }
  },
  "aggs": {
    "sizes": {
      "terms": {
        "field": "_size", (2)
        "size": 10
      }
    }
  },
  "sort": [
    {
      "_size": { (3)
        "order": "desc"
      }
    }
  ],
  "script_fields": {
    "size": {
      "script": "doc['_size']"  (4)
    }
  }
}
  1. Querying on the _size field

  2. Aggregating on the _size field

  3. Sorting on the _size field

  4. Accessing the _size field in scripts (inline scripts must be modules-security-scripting.html#enable-dynamic-scripting[enabled] for this example to work)