| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 | --:api: term-vectors:request: TermVectorsRequest:response: TermVectorsResponse--[id="{upid}-{api}"]=== Term Vectors APITerm Vectors API returns information and statistics on terms in the fieldsof a particular document. The document could be stored in the index orartificially provided by the user.[id="{upid}-{api}-request"]==== Term Vectors RequestA +{request}+ expects an `index` and an `id` to specifya certain document, and fields for which the information is retrieved.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[{api}-request]--------------------------------------------------Term vectors can also be generated for artificial documents, that is fordocuments not present in the index:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[{api}-request-artificial]--------------------------------------------------<1> An artificial document is provided as an `XContentBuilder` object,the Elasticsearch built-in helper to generate JSON content.===== Optional arguments["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[{api}-request-optional-arguments]--------------------------------------------------<1> Set `fieldStatistics` to `false` (default is `true`) to omit document count,sum of document frequencies, sum of total term frequencies.<2> Set `termStatistics` to `true` (default is `false`) to displaytotal term frequency and document frequency.<3> Set `positions` to `false` (default is `true`) to omit the output ofpositions.<4> Set `offsets` to `false` (default is `true`) to omit the output ofoffsets.<5> Set `payloads` to `false` (default is `true`) to omit the output ofpayloads.<6> Set `filterSettings` to filter the terms that can be returned basedon their tf-idf scores.<7> Set `perFieldAnalyzer` to specify a different analyzer thanthe one that the field has.<8> Set `realtime` to `false` (default is `true`) to retrieve term vectorsnear realtime.<9> Set a routing parameterinclude::../execution.asciidoc[][id="{upid}-{api}-response"]==== Term Vectors Response+{response}+ contains the following information:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[{api}-response]--------------------------------------------------<1> The index name of the document.<2> The id of the document.<3> Indicates whether or not the document found.===== Inspecting Term VectorsIf +{response}+ contains non-null list of term vectors,more information about each term vector can be obtained using the following:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[{api}-term-vectors]--------------------------------------------------<1> The name of the current field<2> Fields statistics for the current field - document count<3> Fields statistics for the current field - sum of total term frequencies<4> Fields statistics for the current field - sum of document frequencies<5> Terms for the current field<6> The name of the term<7> Term frequency of the term<8> Document frequency of the term<9> Total term frequency of the term<10> Score of the term<11> Tokens of the term<12> Position of the token<13> Start offset of the token<14> End offset of the token<15> Payload of the token
 |