Is it possible to fetch a document by term ID within a search/rescore plugin?

Hi, I have a concept that I'm thinking about implementing, but before I get my hands dirty, I would like to ask if this is possible. Advisory: Elasticsearch is new to me.

Suppose I have a index cars with document term ids as: toyota_camry, honda_civic, and jeep_wrangler. The document would contain attributes about that car.

Suppose I made a custom plugin that scores my cars/_search results to rank cars that is more recommended for you. Suppose my _search query looks like this (I pass an _id to the plugin and expect the plugin to look it up):

{
  "query": {"terms":{ "_id": ["toyota_camry", "jeep_wrangler "]}},
  "rescore": {"my_plugin": {"car_key": "honda_civic"}}
}

Given that honda_civic is not part of the query, the honda is not found by the search query. From within the data nodes, can I some how fetch the document by id honda_civic and access it in my plugin? I want to be able to access the honda document, without having to provide it in or returned as a search result. The rescoring will be handled based on the user's car_key, the result would score the terms "toyota_camry", "jeep_wrangler " differently and may score toyota_camry above jeep_wrangler because the toyota is more like the honda.

If there is such a feature, is this inter-index look up considered fast/slow? This isn't really a join across multiple indexes.

whenever you have to execute another query, I would consider it slow. You could probably implement that by writing your own SearchPlugin that implements a custom rescorer.

However, maybe something like rank feature datatype or the vector datatype could help you already a bit, allowing you to execute only one query.

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