elasticsearch/_async/client/__init__.py [5810:5963]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        self,
        *,
        index: str,
        id: t.Optional[str] = None,
        doc: t.Optional[t.Mapping[str, t.Any]] = None,
        error_trace: t.Optional[bool] = None,
        field_statistics: t.Optional[bool] = None,
        fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
        filter: t.Optional[t.Mapping[str, t.Any]] = None,
        filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
        human: t.Optional[bool] = None,
        offsets: t.Optional[bool] = None,
        payloads: t.Optional[bool] = None,
        per_field_analyzer: t.Optional[t.Mapping[str, str]] = None,
        positions: t.Optional[bool] = None,
        preference: t.Optional[str] = None,
        pretty: t.Optional[bool] = None,
        realtime: t.Optional[bool] = None,
        routing: t.Optional[str] = None,
        term_statistics: t.Optional[bool] = None,
        version: t.Optional[int] = None,
        version_type: t.Optional[
            t.Union[str, t.Literal["external", "external_gte", "force", "internal"]]
        ] = None,
        body: t.Optional[t.Dict[str, t.Any]] = None,
    ) -> ObjectApiResponse[t.Any]:
        """
        .. raw:: html

          <p>Get term vector information.</p>
          <p>Get information and statistics about terms in the fields of a particular document.</p>
          <p>You can retrieve term vectors for documents stored in the index or for artificial documents passed in the body of the request.
          You can specify the fields you are interested in through the <code>fields</code> parameter or by adding the fields to the request body.
          For example:</p>
          <pre><code>GET /my-index-000001/_termvectors/1?fields=message
          </code></pre>
          <p>Fields can be specified using wildcards, similar to the multi match query.</p>
          <p>Term vectors are real-time by default, not near real-time.
          This can be changed by setting <code>realtime</code> parameter to <code>false</code>.</p>
          <p>You can request three types of values: <em>term information</em>, <em>term statistics</em>, and <em>field statistics</em>.
          By default, all term information and field statistics are returned for all fields but term statistics are excluded.</p>
          <p><strong>Term information</strong></p>
          <ul>
          <li>term frequency in the field (always returned)</li>
          <li>term positions (<code>positions: true</code>)</li>
          <li>start and end offsets (<code>offsets: true</code>)</li>
          <li>term payloads (<code>payloads: true</code>), as base64 encoded bytes</li>
          </ul>
          <p>If the requested information wasn't stored in the index, it will be computed on the fly if possible.
          Additionally, term vectors could be computed for documents not even existing in the index, but instead provided by the user.</p>
          <blockquote>
          <p>warn
          Start and end offsets assume UTF-16 encoding is being used. If you want to use these offsets in order to get the original text that produced this token, you should make sure that the string you are taking a sub-string of is also encoded using UTF-16.</p>
          </blockquote>
          <p><strong>Behaviour</strong></p>
          <p>The term and field statistics are not accurate.
          Deleted documents are not taken into account.
          The information is only retrieved for the shard the requested document resides in.
          The term and field statistics are therefore only useful as relative measures whereas the absolute numbers have no meaning in this context.
          By default, when requesting term vectors of artificial documents, a shard to get the statistics from is randomly selected.
          Use <code>routing</code> only to hit a particular shard.</p>


        `<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-termvectors>`_

        :param index: The name of the index that contains the document.
        :param id: A unique identifier for the document.
        :param doc: An artificial document (a document not present in the index) for
            which you want to retrieve term vectors.
        :param field_statistics: If `true`, the response includes: * The document count
            (how many documents contain this field). * The sum of document frequencies
            (the sum of document frequencies for all terms in this field). * The sum
            of total term frequencies (the sum of total term frequencies of each term
            in this field).
        :param fields: A list of fields to include in the statistics. It is used as the
            default list unless a specific field list is provided in the `completion_fields`
            or `fielddata_fields` parameters.
        :param filter: Filter terms based on their tf-idf scores. This could be useful
            in order find out a good characteristic vector of a document. This feature
            works in a similar manner to the second phase of the More Like This Query.
        :param offsets: If `true`, the response includes term offsets.
        :param payloads: If `true`, the response includes term payloads.
        :param per_field_analyzer: Override the default per-field analyzer. This is useful
            in order to generate term vectors in any fashion, especially when using artificial
            documents. When providing an analyzer for a field that already stores term
            vectors, the term vectors will be regenerated.
        :param positions: If `true`, the response includes term positions.
        :param preference: The node or shard the operation should be performed on. It
            is random by default.
        :param realtime: If true, the request is real-time as opposed to near-real-time.
        :param routing: A custom value that is used to route operations to a specific
            shard.
        :param term_statistics: If `true`, the response includes: * The total term frequency
            (how often a term occurs in all documents). * The document frequency (the
            number of documents containing the current term). By default these values
            are not returned since term statistics can have a serious performance impact.
        :param version: If `true`, returns the document version as part of a hit.
        :param version_type: The version type.
        """
        if index in SKIP_IN_PATH:
            raise ValueError("Empty value passed for parameter 'index'")
        __path_parts: t.Dict[str, str]
        if index not in SKIP_IN_PATH and id not in SKIP_IN_PATH:
            __path_parts = {"index": _quote(index), "id": _quote(id)}
            __path = f'/{__path_parts["index"]}/_termvectors/{__path_parts["id"]}'
        elif index not in SKIP_IN_PATH:
            __path_parts = {"index": _quote(index)}
            __path = f'/{__path_parts["index"]}/_termvectors'
        else:
            raise ValueError("Couldn't find a path for the given parameters")
        __query: t.Dict[str, t.Any] = {}
        __body: t.Dict[str, t.Any] = body if body is not None else {}
        if error_trace is not None:
            __query["error_trace"] = error_trace
        if filter_path is not None:
            __query["filter_path"] = filter_path
        if human is not None:
            __query["human"] = human
        if preference is not None:
            __query["preference"] = preference
        if pretty is not None:
            __query["pretty"] = pretty
        if realtime is not None:
            __query["realtime"] = realtime
        if not __body:
            if doc is not None:
                __body["doc"] = doc
            if field_statistics is not None:
                __body["field_statistics"] = field_statistics
            if fields is not None:
                __body["fields"] = fields
            if filter is not None:
                __body["filter"] = filter
            if offsets is not None:
                __body["offsets"] = offsets
            if payloads is not None:
                __body["payloads"] = payloads
            if per_field_analyzer is not None:
                __body["per_field_analyzer"] = per_field_analyzer
            if positions is not None:
                __body["positions"] = positions
            if routing is not None:
                __body["routing"] = routing
            if term_statistics is not None:
                __body["term_statistics"] = term_statistics
            if version is not None:
                __body["version"] = version
            if version_type is not None:
                __body["version_type"] = version_type
        if not __body:
            __body = None  # type: ignore[assignment]
        __headers = {"accept": "application/json"}
        if __body is not None:
            __headers["content-type"] = "application/json"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



elasticsearch/_sync/client/__init__.py [5808:5961]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        self,
        *,
        index: str,
        id: t.Optional[str] = None,
        doc: t.Optional[t.Mapping[str, t.Any]] = None,
        error_trace: t.Optional[bool] = None,
        field_statistics: t.Optional[bool] = None,
        fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
        filter: t.Optional[t.Mapping[str, t.Any]] = None,
        filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
        human: t.Optional[bool] = None,
        offsets: t.Optional[bool] = None,
        payloads: t.Optional[bool] = None,
        per_field_analyzer: t.Optional[t.Mapping[str, str]] = None,
        positions: t.Optional[bool] = None,
        preference: t.Optional[str] = None,
        pretty: t.Optional[bool] = None,
        realtime: t.Optional[bool] = None,
        routing: t.Optional[str] = None,
        term_statistics: t.Optional[bool] = None,
        version: t.Optional[int] = None,
        version_type: t.Optional[
            t.Union[str, t.Literal["external", "external_gte", "force", "internal"]]
        ] = None,
        body: t.Optional[t.Dict[str, t.Any]] = None,
    ) -> ObjectApiResponse[t.Any]:
        """
        .. raw:: html

          <p>Get term vector information.</p>
          <p>Get information and statistics about terms in the fields of a particular document.</p>
          <p>You can retrieve term vectors for documents stored in the index or for artificial documents passed in the body of the request.
          You can specify the fields you are interested in through the <code>fields</code> parameter or by adding the fields to the request body.
          For example:</p>
          <pre><code>GET /my-index-000001/_termvectors/1?fields=message
          </code></pre>
          <p>Fields can be specified using wildcards, similar to the multi match query.</p>
          <p>Term vectors are real-time by default, not near real-time.
          This can be changed by setting <code>realtime</code> parameter to <code>false</code>.</p>
          <p>You can request three types of values: <em>term information</em>, <em>term statistics</em>, and <em>field statistics</em>.
          By default, all term information and field statistics are returned for all fields but term statistics are excluded.</p>
          <p><strong>Term information</strong></p>
          <ul>
          <li>term frequency in the field (always returned)</li>
          <li>term positions (<code>positions: true</code>)</li>
          <li>start and end offsets (<code>offsets: true</code>)</li>
          <li>term payloads (<code>payloads: true</code>), as base64 encoded bytes</li>
          </ul>
          <p>If the requested information wasn't stored in the index, it will be computed on the fly if possible.
          Additionally, term vectors could be computed for documents not even existing in the index, but instead provided by the user.</p>
          <blockquote>
          <p>warn
          Start and end offsets assume UTF-16 encoding is being used. If you want to use these offsets in order to get the original text that produced this token, you should make sure that the string you are taking a sub-string of is also encoded using UTF-16.</p>
          </blockquote>
          <p><strong>Behaviour</strong></p>
          <p>The term and field statistics are not accurate.
          Deleted documents are not taken into account.
          The information is only retrieved for the shard the requested document resides in.
          The term and field statistics are therefore only useful as relative measures whereas the absolute numbers have no meaning in this context.
          By default, when requesting term vectors of artificial documents, a shard to get the statistics from is randomly selected.
          Use <code>routing</code> only to hit a particular shard.</p>


        `<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-termvectors>`_

        :param index: The name of the index that contains the document.
        :param id: A unique identifier for the document.
        :param doc: An artificial document (a document not present in the index) for
            which you want to retrieve term vectors.
        :param field_statistics: If `true`, the response includes: * The document count
            (how many documents contain this field). * The sum of document frequencies
            (the sum of document frequencies for all terms in this field). * The sum
            of total term frequencies (the sum of total term frequencies of each term
            in this field).
        :param fields: A list of fields to include in the statistics. It is used as the
            default list unless a specific field list is provided in the `completion_fields`
            or `fielddata_fields` parameters.
        :param filter: Filter terms based on their tf-idf scores. This could be useful
            in order find out a good characteristic vector of a document. This feature
            works in a similar manner to the second phase of the More Like This Query.
        :param offsets: If `true`, the response includes term offsets.
        :param payloads: If `true`, the response includes term payloads.
        :param per_field_analyzer: Override the default per-field analyzer. This is useful
            in order to generate term vectors in any fashion, especially when using artificial
            documents. When providing an analyzer for a field that already stores term
            vectors, the term vectors will be regenerated.
        :param positions: If `true`, the response includes term positions.
        :param preference: The node or shard the operation should be performed on. It
            is random by default.
        :param realtime: If true, the request is real-time as opposed to near-real-time.
        :param routing: A custom value that is used to route operations to a specific
            shard.
        :param term_statistics: If `true`, the response includes: * The total term frequency
            (how often a term occurs in all documents). * The document frequency (the
            number of documents containing the current term). By default these values
            are not returned since term statistics can have a serious performance impact.
        :param version: If `true`, returns the document version as part of a hit.
        :param version_type: The version type.
        """
        if index in SKIP_IN_PATH:
            raise ValueError("Empty value passed for parameter 'index'")
        __path_parts: t.Dict[str, str]
        if index not in SKIP_IN_PATH and id not in SKIP_IN_PATH:
            __path_parts = {"index": _quote(index), "id": _quote(id)}
            __path = f'/{__path_parts["index"]}/_termvectors/{__path_parts["id"]}'
        elif index not in SKIP_IN_PATH:
            __path_parts = {"index": _quote(index)}
            __path = f'/{__path_parts["index"]}/_termvectors'
        else:
            raise ValueError("Couldn't find a path for the given parameters")
        __query: t.Dict[str, t.Any] = {}
        __body: t.Dict[str, t.Any] = body if body is not None else {}
        if error_trace is not None:
            __query["error_trace"] = error_trace
        if filter_path is not None:
            __query["filter_path"] = filter_path
        if human is not None:
            __query["human"] = human
        if preference is not None:
            __query["preference"] = preference
        if pretty is not None:
            __query["pretty"] = pretty
        if realtime is not None:
            __query["realtime"] = realtime
        if not __body:
            if doc is not None:
                __body["doc"] = doc
            if field_statistics is not None:
                __body["field_statistics"] = field_statistics
            if fields is not None:
                __body["fields"] = fields
            if filter is not None:
                __body["filter"] = filter
            if offsets is not None:
                __body["offsets"] = offsets
            if payloads is not None:
                __body["payloads"] = payloads
            if per_field_analyzer is not None:
                __body["per_field_analyzer"] = per_field_analyzer
            if positions is not None:
                __body["positions"] = positions
            if routing is not None:
                __body["routing"] = routing
            if term_statistics is not None:
                __body["term_statistics"] = term_statistics
            if version is not None:
                __body["version"] = version
            if version_type is not None:
                __body["version_type"] = version_type
        if not __body:
            __body = None  # type: ignore[assignment]
        __headers = {"accept": "application/json"}
        if __body is not None:
            __headers["content-type"] = "application/json"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



