Skip to content

Instantly share code, notes, and snippets.

@clintongormley
Created May 23, 2014 10:04
Show Gist options
  • Select an option

  • Save clintongormley/1da07e7576f38713e5c5 to your computer and use it in GitHub Desktop.

Select an option

Save clintongormley/1da07e7576f38713e5c5 to your computer and use it in GitHub Desktop.

Revisions

  1. clintongormley created this gist May 23, 2014.
    104 changes: 104 additions & 0 deletions demo.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,104 @@


    DELETE /_all

    PUT /t
    {
    "mappings": {
    "test": {
    "properties": {
    "text": {
    "type": "string",
    "analyzer": "english",
    "fields": {
    "count": {
    "type": "token_count",
    "analyzer": "english"
    }
    }
    }
    }
    }
    }
    }

    PUT /t/test/1
    {
    "text": "baseball bats"
    }

    GET /t/_analyze?field=text&text=baseball glove and hat

    GET /t/test/_search
    {
    "query": {
    "match": {
    "text": "baseball glove and hat"
    }
    },
    "rescore": {
    "window_size": 1000,
    "query": {
    "score_mode": "multiply",
    "rescore_query": {
    "function_score": {
    "query": {
    "function_score": {
    "score_mode": "sum",
    "boost_mode": "replace",
    "functions": [
    {
    "filter": {
    "match_all": {}
    },
    "boost_factor": 0
    },
    {
    "filter": {
    "term": {
    "text": "basebal",
    "_cache": false
    }
    },
    "boost_factor": 1
    },
    {
    "filter": {
    "term": {
    "text": "glove",
    "_cache": false
    }
    },
    "boost_factor": 1
    },
    {
    "filter": {
    "term": {
    "text": "bat",
    "_cache": false
    }
    },
    "boost_factor": 1
    }
    ]
    }
    },
    "boost_mode": "replace",
    "score_mode": "first",
    "functions": [
    {
    "filter": {
    "match_all": {}
    },
    "script_score": {
    "script": "return (_score < doc['text.count'].value) ? 0: 1"
    }
    }
    ]
    }
    }
    }
    }
    }