Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion content/develop/ai/redisvl/api/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ Reference documentation for the RedisVL API.
* [Schema](schema/)
* [IndexSchema](schema/#indexschema)
* [Defining Fields](schema/#defining-fields)
* [Supported Field Types and Attributes](schema/#supported-field-types-and-attributes)
* [Basic Field Types](schema/#basic-field-types)
* [Vector Field Types](schema/#vector-field-types)
* [SVS-VAMANA Configuration Utilities](schema/#svs-vamana-configuration-utilities)
* [Vector Algorithm Comparison](schema/#vector-algorithm-comparison)
* [Search Index Classes](searchindex/)
* [SearchIndex](searchindex/#searchindex)
* [AsyncSearchIndex](searchindex/#asyncsearchindex)
Expand Down
81 changes: 50 additions & 31 deletions content/develop/ai/redisvl/api/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -730,39 +730,18 @@ Return self as the query object.

## HybridQuery

### `class HybridQuery(text, text_field_name, vector, vector_field_name, text_scorer='BM25STD', filter_expression=None, alpha=0.7, dtype='float32', num_results=10, return_fields=None, stopwords='english', dialect=2)`
### `class HybridQuery(*args, **kwargs)`

Bases: `AggregationQuery`

HybridQuery combines text and vector search in Redis.
It allows you to perform a hybrid search using both text and vector similarity.
It scores documents based on a weighted combination of text and vector similarity.

```python
from redisvl.query import HybridQuery
from redisvl.index import SearchIndex
Bases: `AggregateHybridQuery`

index = SearchIndex.from_yaml("path/to/index.yaml")
Backward compatibility wrapper for AggregateHybridQuery.

query = HybridQuery(
text="example text",
text_field_name="text_field",
vector=[0.1, 0.2, 0.3],
vector_field_name="vector_field",
text_scorer="BM25STD",
filter_expression=None,
alpha=0.7,
dtype="float32",
num_results=10,
return_fields=["field1", "field2"],
stopwords="english",
dialect=2,
)

results = index.query(query)
```
#### `Deprecated`
Deprecated since version HybridQuery: is a backward compatibility wrapper around AggregateHybridQuery
and will eventually be replaced with a new hybrid query implementation.
To maintain current functionality please use AggregateHybridQuery directly.",

Instantiates a HybridQuery object.
Instantiates a AggregateHybridQuery object.

* **Parameters:**
* **text** (*str*) – The text to search for.
Expand All @@ -785,6 +764,9 @@ Instantiates a HybridQuery object.
set, or tuple of strings is provided then those will be used as stopwords.
Defaults to "english". if set to "None" then no stopwords will be removed.
* **dialect** (*int* *,* *optional*) – The Redis dialect version. Defaults to 2.
* **text_weights** (*Optional* *[* *Dict* *[* *str* *,* *float* *]* *]*) – The importance weighting of individual words
within the query text. Defaults to None, as no modifications will be made to the
text_scorer score.
* **Raises:**
* **ValueError** – If the text string is empty, or if the text string becomes empty after
stopwords are removed.
Expand Down Expand Up @@ -922,6 +904,14 @@ Default is TFIDF.
* **Return type:**
*AggregateRequest*

#### `set_text_weights(weights)`

Set or update the text weights for the query.

* **Parameters:**
* **text_weights** – Dictionary of word:weight mappings
* **weights** (*Dict* *[* *str* *,* *float* *]*)

#### `sort_by(*fields, **kwargs)`

Indicate how the results should be sorted. This can also be used for
Expand Down Expand Up @@ -975,9 +965,18 @@ Return the stopwords used in the query.
:returns: The stopwords used in the query.
:rtype: Set[str]

#### `property text_weights: Dict[str, float]`

Get the text weights.

* **Returns:**
weight mappings.
* **Return type:**
Dictionary of word

## TextQuery

### `class TextQuery(text, text_field_name, text_scorer='BM25STD', filter_expression=None, return_fields=None, num_results=10, return_score=True, dialect=2, sort_by=None, in_order=False, params=None, stopwords='english')`
### `class TextQuery(text, text_field_name, text_scorer='BM25STD', filter_expression=None, return_fields=None, num_results=10, return_score=True, dialect=2, sort_by=None, in_order=False, params=None, stopwords='english', text_weights=None)`

Bases: `BaseQuery`

Expand Down Expand Up @@ -1038,6 +1037,9 @@ A query for running a full text search, along with an optional filter expression
a default set of stopwords for that language will be used. Users may specify
their own stop words by providing a List or Set of words. if set to None,
then no words will be removed. Defaults to ‘english’.
* **text_weights** (*Optional* *[* *Dict* *[* *str* *,* *float* *]* *]*) – The importance weighting of individual words
within the query text. Defaults to None, as no modifications will be made to the
text_scorer score.
* **Raises:**
* **ValueError** – if stopwords language string cannot be loaded.
* **TypeError** – If stopwords is not a valid iterable set of strings.
Expand Down Expand Up @@ -1184,6 +1186,14 @@ Set the filter expression for the query.
* **Raises:**
**TypeError** – If filter_expression is not a valid FilterExpression or string.

#### `set_text_weights(weights)`

Set or update the text weights for the query.

* **Parameters:**
* **text_weights** – Dictionary of word:weight mappings
* **weights** (*Dict* *[* *str* *,* *float* *]*)

#### `slop(slop)`

Allow a maximum of N intervening non matched terms between
Expand Down Expand Up @@ -1289,6 +1299,15 @@ Get the text field name(s) - for backward compatibility.
Either a single field name string (if only one field with weight 1.0)
or a dictionary of field:weight mappings.

#### `property text_weights: Dict[str, float]`

Get the text weights.

* **Returns:**
weight mappings.
* **Return type:**
Dictionary of word

## FilterQuery

### `class FilterQuery(filter_expression=None, return_fields=None, num_results=10, dialect=2, sort_by=None, in_order=False, params=None)`
Expand Down Expand Up @@ -1797,7 +1816,7 @@ Return self as the query object.

Bases: `AggregationQuery`

MultiVectorQuery allows for search over multiple vector fields in a document simulateously.
MultiVectorQuery allows for search over multiple vector fields in a document simultaneously.
The final score will be a weighted combination of the individual vector similarity scores
following the formula:

Expand Down
Loading