I want to recalculate the score according to the tf and idf according to the term_vector from elasticsearch, so I need :
- query's tokens splitted by analyzer(i use ik_max_word) of elasticsearch
- best matched document id
- the term_vector of best matched document
I also find the ways to get all those infos by three step:
- firstly, get best match document index from es and get document
_id
fromresult['hits']['hits'][0]["_id"]
. - secondly, get document term_vector use :
curl -XGET 'http://localhost:9200/my_index/my_doc_type/best_match_index/_termvector?pretty=true'
wherebest_match_index
is the_id
in first step. according to https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html#docs-termvectors-terms-filtering - Then, get the splitted tokens of query use es analyzer
curl -H "Content-Type: application/json" -XGET 'http://127.0.0.1:9200/my_index/_analyze?pretty=true' -d '{"field": "context", "text": "this is the test text"}'
. According to https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html#docs-termvectors-terms-filtering
In other words, I need three times request result from es server. Any method i get all those infos from es in one time?
thx