Share via


text_search Package

Modules

text_search
text_search_filter
text_search_options
text_search_result
utils
vector_store_text_search

Classes

OptionsUpdateFunctionType

Type definition for the options update function in Text Search.

TextSearch

The base class for all text searches.

Note: This class is marked as 'experimental' and may change in the future.

TextSearchFilter

A filter clause for a text search query.

Note: This class is marked as 'experimental' and may change in the future.

Initialize a new instance of SearchFilter.

TextSearchOptions

Options for a text search.

Note: This class is marked as 'experimental' and may change in the future.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

TextSearchResult

The result of a text search.

Note: This class is marked as 'experimental' and may change in the future.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

VectorStoreTextSearch

Class that wraps a Vector Store Record Collection to expose as a Text Search.

Preferably the class methods are used to create an instance of this class. Otherwise the search executes in the following order depending on which store was set:

  1. vectorizable_text_search
  2. vector_text_search
  3. vectorized_search (after calling the embedding service)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Functions

create_options

Create search options.

If options are supplied, they are checked for the right type, and the kwargs are used to update the options.

If options are not supplied, they are created from the kwargs. If that fails, an empty options object is returned.

create_options(options_class: type[SearchOptions], options: SearchOptions | None, **kwargs: Any) -> SearchOptions

Parameters

Name Description
options_class
Required

The class of the options.

options
Required

The existing options to update.

**kwargs
Required

The keyword arguments to use to create the options.

Returns

Type Description

The options.

Exceptions

Type Description
ValidationError

If the options are not valid.

default_options_update_function

The default options update function.

This function is used to update the query and options with the kwargs. You can supply your own version of this function to customize the behavior.

default_options_update_function(query: str, options: SearchOptions, parameters: list[KernelParameterMetadata] | None = None, **kwargs: Any) -> tuple[str, SearchOptions]

Parameters

Name Description
query
Required

The query.

options
Required

The options.

parameters

The parameters to use to create the options.

Default value: None
**kwargs
Required

The keyword arguments to use to update the options.

Returns

Type Description

The updated query and options