{"id":21994504,"url":"https://github.com/codelibs/elasticsearch-dynarank","last_synced_at":"2025-04-30T17:01:40.423Z","repository":{"id":20082993,"uuid":"23352046","full_name":"codelibs/elasticsearch-dynarank","owner":"codelibs","description":"This plugin provides a feature to change top N documents in a search result.","archived":false,"fork":false,"pushed_at":"2023-06-14T22:29:04.000Z","size":234,"stargazers_count":56,"open_issues_count":4,"forks_count":16,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-30T18:04:35.483Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codelibs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-26T13:08:58.000Z","updated_at":"2024-06-24T07:21:45.000Z","dependencies_parsed_at":"2022-09-02T14:31:21.469Z","dependency_job_id":null,"html_url":"https://github.com/codelibs/elasticsearch-dynarank","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelibs%2Felasticsearch-dynarank","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelibs%2Felasticsearch-dynarank/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelibs%2Felasticsearch-dynarank/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelibs%2Felasticsearch-dynarank/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codelibs","download_url":"https://codeload.github.com/codelibs/elasticsearch-dynarank/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251748929,"owners_count":21637413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T21:09:32.454Z","updated_at":"2025-04-30T17:01:39.369Z","avatar_url":"https://github.com/codelibs.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Elasticsearch DynaRank Plugin\n=======================\n\n## Overview\n\nDynaRank Plugin provides a feature for Dynamic Ranking at a search time.\nYou can change top N documents in the search result with your re-ordering algorithm.\nElasticsearch has [rescoring](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-rescore.html \"rescoring\"), but DynaRank is different as below:\n\n * DynaRank's reranking is executed on requested node only, not on each shard. \n * DynaRank uses a script language for reranking.\n\n\n## Version\n\n[Versions in Maven Repository](https://repo1.maven.org/maven2/org/codelibs/elasticsearch-dynarank/)\n\n### Issues/Questions\n\nPlease file an [issue](https://github.com/codelibs/elasticsearch-dynarank/issues \"issue\").\n\n## Installation\n\n    $ $ES_HOME/bin/elasticsearch-plugin install org.codelibs:elasticsearch-dynarank:7.16.0\n\n## Getting Started\n\n### Create Sample Data\n\nCreate \"sample\" index:\n\n    $ COUNT=1;while [ $COUNT -le 100 ] ; do curl -XPOST 'localhost:9200/sample/_doc/' -d \"{\\\"message\\\":\\\"Hello $COUNT\\\",\\\"counter\\\":$COUNT}\";COUNT=`expr $COUNT + 1`; done\n\n100 documents are inserted. You can see 10 documents by an ascending order of \"counter\" field:\n\n    $ curl -XPOST \"http://127.0.0.1:9200/sample/_search\" -d'\n    {\n       \"query\": {\n          \"match_all\": {}\n       },\n       \"sort\": [\n          {\n             \"counter\": {\n                 \"order\": \"asc\"\n             }\n          }\n       ]\n    }'\n\n### Enable Reranking\n\nDynaRank plugin is enabled if your re-order script is set to the target index:\n\n```\n$ curl -s -XPUT -H 'Content-Type: application/json' \"localhost:9200/sample/_settings\" -d\"\n{\n  \\\"index\\\" : {\n    \\\"dynarank\\\":{\n      \\\"script_sort\\\":{\n        \\\"lang\\\": \\\"painless\\\",\n        \\\"script\\\": \\\"def l=new ArrayList();for(def h:searchHits){l.add(h);}return l.stream().sorted((s1,s2)-\u003es2.getSourceAsMap().get('counter')-s1.getSourceAsMap().get('counter')).toArray(n-\u003enew org.elasticsearch.search.SearchHit[n])\\\"\n      },\n      \\\"reorder_size\\\": 5\n     }\n  }\n}\"\n```\n\nThis 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.\n\n### Disable Reranking\n\nSet an empty value to index.dynarank.script\\_sort.script:\n\n```\n$ curl -s -XPUT -H 'Content-Type: application/json' \"localhost:9200/sample/_settings\" -d\"\n{\n  \\\"index\\\" : {\n    \\\"dynarank\\\":{\n      \\\"script_sort\\\":{\n        \\\"script\\\": \\\"\\\"\n      }\n     }\n  }\n}\"\n```\n\n## References\n\n### dynarank\\_diversity\\_sort Script Sort\n\nDynaRank plugin provides a sort feature for a diversity problem.\nThe sort script is dynarank\\_diversity\\_sort.\nThe configuration is below:\n\n    curl -XPUT -H 'Content-Type: application/json' 'localhost:9200/sample/_settings' -d '\n    {\n      \"index\" : {\n        \"dynarank\":{\n          \"script_sort\":{\n            \"lang\":\"dynarank_diversity_sort\",\n            \"params\":{\n              \"bucket_factory\": \"standard\",\n              \"diversity_fields\":[\"filedname1\", \"filedname2\"],\n              \"diversity_thresholds\":[0.95, 1]\n            }\n          },\n          \"reorder_size\":100\n         }\n      }\n    }'\n\nbucket\\_factory is bucket type. use minhash type field for sort, specify \"minhash\".(default: standard)  \ndiversity\\_fields is fields for a diversity.  \ndiversity\\_thresholds is a threshold for a similarity of each document.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodelibs%2Felasticsearch-dynarank","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodelibs%2Felasticsearch-dynarank","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodelibs%2Felasticsearch-dynarank/lists"}