OpenSearch/docs/reference
Britta Weber 1ede9a5730 make term statistics accessible in scripts
term statistics can be accessed via the _shard variable.

Below is a minimal example. See documentation on details.

```

DELETE paytest

PUT paytest
{
    "mappings": {
        "test": {
            "_all": {
                "auto_boost": true,
                "enabled": true
            },
            "properties": {
                "text": {
                    "index_analyzer": "fulltext_analyzer",
                    "store": "yes",
                    "type": "string"
                }
            }
        }
    },
    "settings": {
        "analysis": {
            "analyzer": {
                "fulltext_analyzer": {
                    "filter": [
                        "my_delimited_payload_filter"
                    ],
                    "tokenizer": "whitespace",
                    "type": "custom"
                }
            },
            "filter": {
                "my_delimited_payload_filter": {
                    "delimiter": "+",
                    "encoding": "float",
                    "type": "delimited_payload_filter"
                }
            }
        },
        "index": {
            "number_of_replicas": 0,
            "number_of_shards": 1
        }
    }
}

POST paytest/test/1
{
    "text": "the+1 quick+2 brown+3 fox+4 is quick+10"
}

POST paytest/test/2
{
    "text": "the+1 quick+2 red+3 fox+4"
}

POST paytest/_refresh

POST paytest/_search
{
    "script_fields": {
       "ttf": {
          "script": "_shard[\"text\"][\"quick\"].ttf()"
       }
    }
}

POST paytest/_search
{
    "script_fields": {
       "freq": {
          "script": "_shard[\"text\"][\"quick\"].freq()"
       }
    }
}
POST paytest/test/2/_termvector
POST paytest/_search
{
    "script_fields": {
       "payloads": {
          "script": "term = _shard[\"text\"].get(\"red\",_PAYLOADS);payloads = []; for(pos : term){payloads.add(pos.payloadAsFloat(-1));} return payloads;"
       }
    }
}

POST paytest/_search
{
   "script_fields": {
      "tv": {
         "script": "_shard[\"text\"][\"quick\"].freq()"
      }
   },
   "query": {
      "function_score": {
         "functions": [
            {
               "script_score": {
                  "script": "_shard[\"text\"][\"quick\"].freq()"
               }
            }
         ]
      }
   }
}

```

closes #3772
2014-01-02 11:17:33 +01:00
..
analysis Wrong link to Token Filter 2013-12-03 10:39:13 +01:00
cat [DOCS] Linked cat-pending to cluster-pending 2013-12-02 15:29:47 +01:00
cluster Added cluster health status to the Cluster Stats API 2013-12-18 12:03:49 +01:00
docs [DOCS] Documented rest.action.multi.allow_explicit_index 2013-11-27 17:33:09 +01:00
images add docs on new service.bat facility 2013-09-23 18:24:31 +03:00
index-modules Doc values for geo points. 2013-12-27 12:45:18 +01:00
indices [DOCS] Documented index.codec.bloom.load for #4525 2013-12-20 10:51:17 +01:00
mapping Explicit doc_values setting. 2013-12-30 11:10:52 +01:00
modules make term statistics accessible in scripts 2014-01-02 11:17:33 +01:00
query-dsl * setup accurate GeoDistance Function 2013-12-27 19:15:19 +09:00
search * setup accurate GeoDistance Function 2013-12-27 19:15:19 +09:00
setup Add repository information to docs 2013-12-19 15:58:08 +01:00
testing [DOCS] Test framework documentation 2013-12-02 18:01:45 +01:00
analysis.asciidoc Add more anchor links to documentation 2013-09-30 13:13:16 -06:00
api-conventions.asciidoc [DOCS] Fixed typos and corrected grammar 2013-12-02 10:08:26 +01:00
cat.asciidoc [DOCS] Add headers and help parameters. 2013-12-23 22:26:28 -06:00
cluster.asciidoc Added Cluster Stats API 2013-12-17 13:14:46 +01:00
docs.asciidoc [DOCS] Reorganised common API conventions 2013-10-13 16:46:56 +02:00
glossary.asciidoc Migrated documentation into the main repo 2013-08-29 01:24:34 +02:00
index-modules.asciidoc Remove 'term_index_interval' and 'term_index_divisor' 2013-12-10 16:54:08 +01:00
index.asciidoc [DOCS] Test framework documentation 2013-12-02 18:01:45 +01:00
indices.asciidoc Add a GetFieldMapping API 2013-10-30 16:16:36 +01:00
mapping.asciidoc Uniquify anchor links to fix asciidoc/docbook generation 2013-09-30 15:32:00 -06:00
modules.asciidoc make term statistics accessible in scripts 2014-01-02 11:17:33 +01:00
query-dsl.asciidoc Migrated documentation into the main repo 2013-08-29 01:24:34 +02:00
search.asciidoc [DOC] add doc for multi term vector api 2013-11-26 17:03:14 +01:00
setup.asciidoc Add repository information to docs 2013-12-19 15:58:08 +01:00
testing.asciidoc [DOCS] Test framework documentation 2013-12-02 18:01:45 +01:00