|
48 | 48 | BaseVectorQuery, |
49 | 49 | CountQuery, |
50 | 50 | FilterQuery, |
51 | | - HybridQuery, |
52 | 51 | ) |
53 | 52 | from redisvl.query.filter import FilterExpression |
54 | 53 | from redisvl.redis.connection import ( |
55 | 54 | RedisConnectionFactory, |
56 | 55 | convert_index_info_to_schema, |
57 | 56 | ) |
58 | | -from redisvl.redis.utils import convert_bytes |
59 | 57 | from redisvl.schema import IndexSchema, StorageType |
60 | | -from redisvl.schema.fields import VECTOR_NORM_MAP, VectorDistanceMetric |
| 58 | +from redisvl.schema.fields import ( |
| 59 | + VECTOR_NORM_MAP, |
| 60 | + VectorDistanceMetric, |
| 61 | + VectorIndexAlgorithm, |
| 62 | +) |
61 | 63 | from redisvl.utils.log import get_logger |
62 | 64 |
|
63 | 65 | logger = get_logger(__name__) |
@@ -196,6 +198,15 @@ def _storage(self) -> BaseStorage: |
196 | 198 | index_schema=self.schema |
197 | 199 | ) |
198 | 200 |
|
| 201 | + def _validate_query(self, query: BaseQuery) -> None: |
| 202 | + """Validate a query.""" |
| 203 | + if isinstance(query, VectorQuery): |
| 204 | + field = self.schema.fields[query._vector_field_name] |
| 205 | + if query.ef_runtime and field.attrs.algorithm != VectorIndexAlgorithm.HNSW: # type: ignore |
| 206 | + raise QueryValidationError( |
| 207 | + "Vector field using 'flat' algorithm does not support EF_RUNTIME query parameter." |
| 208 | + ) |
| 209 | + |
199 | 210 | @property |
200 | 211 | def name(self) -> str: |
201 | 212 | """The name of the Redis search index.""" |
@@ -837,15 +848,6 @@ def batch_query( |
837 | 848 | all_parsed.append(parsed) |
838 | 849 | return all_parsed |
839 | 850 |
|
840 | | - def _validate_query(self, query: BaseQuery) -> None: |
841 | | - """Validate a query.""" |
842 | | - if isinstance(query, VectorQuery): |
843 | | - field = self.schema.fields[query._vector_field_name] |
844 | | - if query.ef_runtime and field.attrs.algorithm != "hnsw": # type: ignore |
845 | | - raise QueryValidationError( |
846 | | - "Flat index does not support vector queries." |
847 | | - ) |
848 | | - |
849 | 851 | def _query(self, query: BaseQuery) -> List[Dict[str, Any]]: |
850 | 852 | """Execute a query and process results.""" |
851 | 853 | try: |
@@ -1416,7 +1418,8 @@ async def _aggregate( |
1416 | 1418 | ) -> List[Dict[str, Any]]: |
1417 | 1419 | """Execute an aggregation query and processes the results.""" |
1418 | 1420 | results = await self.aggregate( |
1419 | | - aggregation_query, query_params=aggregation_query.params # type: ignore[attr-defined] |
| 1421 | + aggregation_query, |
| 1422 | + query_params=aggregation_query.params, # type: ignore[attr-defined] |
1420 | 1423 | ) |
1421 | 1424 | return process_aggregate_results( |
1422 | 1425 | results, |
@@ -1542,15 +1545,6 @@ async def batch_query( |
1542 | 1545 |
|
1543 | 1546 | return all_parsed |
1544 | 1547 |
|
1545 | | - def _validate_query(self, query: BaseQuery) -> None: |
1546 | | - """Validate a query.""" |
1547 | | - if isinstance(query, VectorQuery): |
1548 | | - field = self.schema.fields[query._vector_field_name] |
1549 | | - if query.ef_runtime and field.attrs.algorithm != "hnsw": # type: ignore |
1550 | | - raise QueryValidationError( |
1551 | | - "Flat index does not support vector queries." |
1552 | | - ) |
1553 | | - |
1554 | 1548 | async def _query(self, query: BaseQuery) -> List[Dict[str, Any]]: |
1555 | 1549 | """Asynchronously execute a query and process results.""" |
1556 | 1550 | try: |
|
0 commit comments