0

Elastic Term vector API (https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html) seems to be focused on getting the term-vector on a per-document basis, the classic user story being "Get me a term vector by Document Id". What if i want to always get term vectors? E.g. i search for documents matching a certain query, and all the documents should be returned with the corresponding term vectors for a certain field.

Is it a possibility or is getting the term-vector right after the index time and storing it somewhere the only workaround?

roykeane
  • 1
  • 1
  • Term vectors cannot be retrieved at search time for all returned documents, unfortunately. Do you mind sharing the use case behind this? – Val Apr 25 '23 at 08:25
  • Thank you, @Val. The user story is the clusterization (and other analysis) of search results. So, the workaround is to get the term vector on indexation time - do you think it's possible to store the term vector in a field? – roykeane Apr 25 '23 at 08:41
  • Term vectors are [already stored](https://www.elastic.co/guide/en/elasticsearch/reference/current/term-vector.html) at indexing time, but you cannot get them out via a search, only via a GET by id. What you can do is to get the term vectors using [artificial documents](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html#docs-termvectors-artificial-doc) and then partial update your document with whatever you get back – Val Apr 25 '23 at 08:43
  • thank you. Yes, looks like analyze API might be a better fit than term vectors (not ideal though...). Also, this request is actually closely related to https://stackoverflow.com/questions/13404722/retrieve-analyzed-tokens-from-elasticsearch-documents – roykeane Apr 25 '23 at 13:50

0 Answers0