Giter VIP home page Giter VIP logo

elasticsearch-dynarank's Introduction

Elasticsearch DynaRank Plugin

Overview

DynaRank Plugin provides a feature for Dynamic Ranking at a search time. You can change top N documents in the search result with your re-ordering algorithm. Elasticsearch has rescoring, but DynaRank is different as below:

  • DynaRank's reranking is executed on requested node only, not on each shard.
  • DynaRank uses a script language for reranking.

Version

Version Elasticsearch
master 2.2.X
2.1.0 2.1.1
1.6.0 1.6.0
1.5.1 1.5.2
1.4.5 1.4.2
1.3.0 1.3.2

Issues/Questions

Please file an issue. (Japanese forum is here.)

Installation

Install DynaRank Plugin

$ $ES_HOME/bin/plugin install org.codelibs/elasticsearch-dynarank/2.1.0

Getting Started

Create Sample Data

Create "sample" index:

$ COUNT=1;while [ $COUNT -le 100 ] ; do curl -XPOST 'localhost:9200/sample/data' -d "{\"message\":\"Hello $COUNT\",\"counter\":$COUNT}";COUNT=`expr $COUNT + 1`; done

100 documents are inserted. You can see 10 documents by an ascending order of "counter" field:

$ curl -XPOST "http://127.0.0.1:9200/sample/data/_search" -d'
{
   "query": {
      "match_all": {}
   },
   "fields": [
      "counter",
      "_source"
   ],
   "sort": [
      {
         "counter": {
             "order": "asc"
         }
      }
   ]
}'

Enable Reranking

DynaRank plugin is enabled if your re-order script is set to the target index:

$ curl -XPUT 'localhost:9200/sample/_settings?index.dynarank.script_sort.script=searchHits.sort%20%7Bs1%2C%20s2%20-%3E%20s2.field%28%27counter%27%29.value%28%29%20-%20s1.field%28%27counter%27%29.value%28%29%7D%20as%20org.elasticsearch.search.internal.InternalSearchHit%5B%5D'
$ curl -XPUT 'localhost:9200/sample/_settings?index.dynarank.reorder_size=5'

The above script is:

searchHits.sort {s1, s2 -> s2.field('counter').value() - s1.field('counter').value()} as org.elasticsearch.search.internal.InternalSearchHit[]

This setting sorts top 5 documents (5 is given by reorder_size) by a descending order of "counter" field, and others are by an ascending order.

Disable Reranking

Set an empty value to index.dynarank.script_sort.script:

$ curl -XPUT 'localhost:9200/sample/_settings?index.dynarank.script_sort.script='

References

dynarank_diversity_sort Script Sort

DynaRank plugin provides a sort feature for a diversity problem. The sort script is dynarank_diversity_sort. The configuration is below:

curl -XPUT 'localhost:9200/sample/_settings' -d '
{
  "index" : {
    "dynarank":{
      "script_sort":{
        "lang":"native",
        "script":"dynarank_diversity_sort",
        "params":{
          "diversity_fields":["filedname1", "filedname2"],
          "diversity_thresholds":[0.95, 1]
        }
      },
      "reorder_size":100
     }
  }
}'

diversity_fields is fields for a diversity. diversity_thresholds is a threshold for a similarity of each document.

elasticsearch-dynarank's People

Contributors

alenegro81 avatar marevol avatar shatake avatar stephlag avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.