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

Versions in Maven Repository

Issues/Questions

Please file an issue.

Installation

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

Getting Started

Create Sample Data

Create "sample" index:

$ COUNT=1;while [ $COUNT -le 100 ] ; do curl -XPOST 'localhost:9200/sample/_doc/' -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/_search" -d'
{
   "query": {
      "match_all": {}
   },
   "sort": [
      {
         "counter": {
             "order": "asc"
         }
      }
   ]
}'

Enable Reranking

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

$ curl -s -XPUT -H 'Content-Type: application/json' "localhost:9200/sample/_settings" -d"
{
  \"index\" : {
    \"dynarank\":{
      \"script_sort\":{
        \"lang\": \"painless\",
        \"script\": \"def l=new ArrayList();for(def h:searchHits){l.add(h);}return l.stream().sorted((s1,s2)->s2.getSourceAsMap().get('counter')-s1.getSourceAsMap().get('counter')).toArray(n->new org.elasticsearch.search.SearchHit[n])\"
      },
      \"reorder_size\": 5
     }
  }
}"

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 -s -XPUT -H 'Content-Type: application/json' "localhost:9200/sample/_settings" -d"
{
  \"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 -H 'Content-Type: application/json' 'localhost:9200/sample/_settings' -d '
{
  "index" : {
    "dynarank":{
      "script_sort":{
        "lang":"dynarank_diversity_sort",
        "params":{
          "bucket_factory": "standard",
          "diversity_fields":["filedname1", "filedname2"],
          "diversity_thresholds":[0.95, 1]
        }
      },
      "reorder_size":100
     }
  }
}'

bucket_factory is bucket type. use minhash type field for sort, specify "minhash".(default: standard)
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 deka0106 avatar dependabot[bot] avatar igarash1 avatar keiichiw avatar marevol avatar matsui-stb avatar shatake avatar stephlag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elasticsearch-dynarank's Issues

SearchActionFilter is called twice

It's difficult for own ActionFIlter to discriminate TransportSearchAction and the subsequent SearchAction.
I think that this problem comes from Elasticsearch's specification issue.

No tutorial on Diversity

Hi,

I could not find how to run Diversity sort query. Only the settings update is mentioned and nothing more.

Please share an explanatory example.

Thanks!

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.