Skip to content

Commit ad8a1a3

Browse files
committed
Termverctor APIs
1 parent 5af6735 commit ad8a1a3

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

elasticsearch/client/__init__.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,3 +745,83 @@ def mlt(self, index, doc_type, id, body=None, params=None):
745745
_, data = self.transport.perform_request('GET', _make_path(index, doc_type, id, '_mlt'),
746746
params=params, body=body)
747747
return data
748+
749+
@query_params('field_statistics', 'fields', 'offsets', 'parent', 'payloads',
750+
'positions', 'preference', 'routing', 'term_statistics')
751+
def termvector(self, index, doc_type, id, body=None, params=None):
752+
"""
753+
Added in 1.
754+
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-termvectors.html>`_
755+
756+
:arg index: The index in which the document resides.
757+
:arg doc_type: The type of the document.
758+
:arg id: The id of the document.
759+
:arg body: Define parameters. See documentation.
760+
:arg field_statistics: Specifies if document count, sum of document
761+
frequencies and sum of total term frequencies should be returned.,
762+
default True
763+
:arg fields: A comma-separated list of fields to return.
764+
:arg offsets: Specifies if term offsets should be returned., default
765+
True
766+
:arg parent: Parent id of documents.
767+
:arg payloads: Specifies if term payloads should be returned., default
768+
True
769+
:arg positions: Specifies if term positions should be returned., default
770+
True
771+
:arg preference: Specify the node or shard the operation should be
772+
performed on (default: random).
773+
:arg routing: Specific routing value.
774+
:arg term_statistics: Specifies if total term frequency and document
775+
frequency should be returned., default False
776+
"""
777+
_, data = self.transport.perform_request('GET', _make_path(index,
778+
doc_type, id, '_termvector'), params=params, body=body)
779+
return data
780+
781+
@query_params('field_statistics', 'fields', 'ids', 'offsets', 'parent',
782+
'payloads', 'positions', 'preference', 'routing', 'term_statistics')
783+
def mtermvectors(self, index=None, doc_type=None, body=None, params=None):
784+
"""
785+
Multi termvectors API allows to get multiple termvectors based on an
786+
index, type and id.
787+
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html>`_
788+
789+
:arg index: The index in which the document resides.
790+
:arg doc_type: The type of the document.
791+
:arg body: Define ids, parameters or a list of parameters per document
792+
here. You must at least provide a list of document ids. See
793+
documentation.
794+
:arg field_statistics: Specifies if document count, sum of document
795+
frequencies and sum of total term frequencies should be returned.
796+
Applies to all returned documents unless otherwise specified in body
797+
"params" or "docs"., default True
798+
:arg fields: A comma-separated list of fields to return. Applies to all
799+
returned documents unless otherwise specified in body "params" or
800+
"docs".
801+
:arg ids: A comma-separated list of documents ids. You must define ids
802+
as parameter or set "ids" or "docs" in the request body
803+
:arg offsets: Specifies if term offsets should be returned. Applies to
804+
all returned documents unless otherwise specified in body "params"
805+
or "docs"., default True
806+
:arg parent: Parent id of documents. Applies to all returned documents
807+
unless otherwise specified in body "params" or "docs".
808+
:arg payloads: Specifies if term payloads should be returned. Applies to
809+
all returned documents unless otherwise specified in body "params"
810+
or "docs"., default True
811+
:arg positions: Specifies if term positions should be returned. Applies
812+
to all returned documents unless otherwise specified in body
813+
"params" or "docs"., default True
814+
:arg preference: Specify the node or shard the operation should be
815+
performed on (default: random) .Applies to all returned documents
816+
unless otherwise specified in body "params" or "docs".
817+
:arg routing: Specific routing value. Applies to all returned documents
818+
unless otherwise specified in body "params" or "docs".
819+
:arg term_statistics: Specifies if total term frequency and document
820+
frequency should be returned. Applies to all returned documents
821+
unless otherwise specified in body "params" or "docs"., default
822+
False
823+
"""
824+
_, data = self.transport.perform_request('GET', _make_path(index,
825+
doc_type, '_mtermvectors'), params=params, body=body)
826+
return data
827+

0 commit comments

Comments
 (0)