# Elasticsearch rescore plugin how to get query object from context?

**URL:** <https://discuss.elastic.co/t/elasticsearch-rescore-plugin-how-to-get-query-object-from-context/291094>\
**Category:** Elasticsearch\
**Created:** [December 7, 2021, 6:44am UTC](https://discuss.elastic.co/t/elasticsearch-rescore-plugin-how-to-get-query-object-from-context/291094 "2021-12-07T06:44:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![oni7uka](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oni7uka/32/98460_2.png) [@oni7uka](https://discuss.elastic.co/u/oni7uka)\
**Post date:** [December 7, 2021, 6:44am UTC](https://discuss.elastic.co/t/elasticsearch-rescore-plugin-how-to-get-query-object-from-context/291094/1 "2021-12-07T06:44:32Z")

</div>

I want to write a custom Elasticsearch rescore plugin, Similar to using Levenshtein algorithm to calculate the similarity between the original query string and the query result. But how do I get the query object? It seems that I cannot retrieve the `Query` object from the `RescoreContext` and `QueryShardContext`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 4, 2022, 6:44am UTC](https://discuss.elastic.co/t/elasticsearch-rescore-plugin-how-to-get-query-object-from-context/291094/2 "2022-01-04T06:44:48Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
