Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make term statistics and term vectors accessible in scripts #4161

Closed
wants to merge 7 commits into from

Commits on Dec 17, 2013

  1. do not call score() twice

    brwe committed Dec 17, 2013
    Configuration menu
    Copy the full SHA
    4489f9c View commit details
    Browse the repository at this point in the history
  2. 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 elastic#3772
    brwe committed Dec 17, 2013
    Configuration menu
    Copy the full SHA
    38688d3 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7718b8d View commit details
    Browse the repository at this point in the history
  4. implemented @s1monw comments

    brwe committed Dec 17, 2013
    Configuration menu
    Copy the full SHA
    0cd0028 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    b132824 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    de7a768 View commit details
    Browse the repository at this point in the history

Commits on Dec 18, 2013

  1. Configuration menu
    Copy the full SHA
    4a0fd70 View commit details
    Browse the repository at this point in the history