Reputation: 168
I am trying to get the positions of the Tokens in a single Search Query.
I know till now that if I want then I have to use two different Queries, one for _termvectors
and the other one for _search
. But I don't want to make two separate queries just to get the positions of the token.
Is there a way to do the same in just one call?
Thanks in Advance for the Help!!!!
Upvotes: 0
Views: 227
Reputation: 2279
I do not think there is a simple solution for your problem.
You may use highlighting
, and perform a post treatment to retrieve the position of the matched tokens. Please read the documentation carefully because highlighting may provide different results compared to termvectors.
If your use case is not to retrieve the position, but for example to boost documents where the tokens appear near the beginning, you may use span first queries
. It allows for example to increase the boost of a document if the term is found in e.g., the first 3 tokens.
Upvotes: 1