Multi term vectors API
editMulti term vectors API
editRetrieves multiple term vectors with a single request.
POST /_mtermvectors { "docs": [ { "_index": "my-index-000001", "_id": "2", "term_statistics": true }, { "_index": "my-index-000001", "_id": "1", "fields": [ "message" ] } ] }
Description
editYou can specify existing documents by index and ID or provide artificial documents in the body of the request. The index can be specified the body of the request or in the request URI.
The response contains a docs
array with all the fetched termvectors.
Each element has the structure provided by the termvectors
API.
See the termvectors API for more information about the information that can be included in the response.
Path parameters
edit-
<index>
- (Optional, string) Name of the index that contains the documents.
Query parameters
edit-
fields
-
(Optional, string) Comma-separated list or wildcard expressions of fields to include in the statistics.
Used as the default list unless a specific field list is provided in the
completion_fields
orfielddata_fields
parameters. -
field_statistics
-
(Optional, Boolean) If
true
, the response includes the document count, sum of document frequencies, and sum of total term frequencies. Defaults totrue
. -
<offsets>
-
(Optional, Boolean) If
true
, the response includes term offsets. Defaults totrue
. -
payloads
-
(Optional, Boolean) If
true
, the response includes term payloads. Defaults totrue
. -
positions
-
(Optional, Boolean) If
true
, the response includes term positions. Defaults totrue
. -
preference
- (Optional, string) Specifies the node or shard the operation should be performed on. Random by default.
-
routing
- (Optional, string) Target the specified primary shard.
-
realtime
-
(Optional, Boolean) If
true
, the request is real-time as opposed to near-real-time. Defaults totrue
. See Realtime. -
term_statistics
-
(Optional, Boolean) If
true
, the response includes term frequency and document frequency. Defaults tofalse
. -
version
-
(Optional, Boolean) If
true
, returns the document version as part of a hit. -
version_type
-
(Optional, enum) Specific version type:
internal
,external
,external_gte
.
Examples
editIf you specify an index in the request URI, the index does not need to be specified for each documents in the request body:
POST /my-index-000001/_mtermvectors { "docs": [ { "_id": "2", "fields": [ "message" ], "term_statistics": true }, { "_id": "1" } ] }
If all requested documents are in same index and the parameters are the same, you can use the following simplified syntax:
POST /my-index-000001/_mtermvectors { "ids": [ "1", "2" ], "parameters": { "fields": [ "message" ], "term_statistics": true } }
Artificial documents
editYou can also use mtermvectors
to generate term vectors for artificial documents provided
in the body of the request. The mapping used is determined by the specified _index
.
POST /_mtermvectors { "docs": [ { "_index": "my-index-000001", "doc" : { "message" : "test test test" } }, { "_index": "my-index-000001", "doc" : { "message" : "Another test ..." } } ] }