Skip to content
Merged
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
18 changes: 12 additions & 6 deletions aredis_om/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1564,11 +1564,17 @@ def _resolve_redisearch_query(self, expression: ExpressionOrNegated) -> str:
result += f"({self._resolve_redisearch_query(right)})"
else:
if not field_name:
raise QuerySyntaxError("Could not resolve field name. See docs: TODO")
raise QuerySyntaxError(
f"Could not resolve field name. Docs: {ERRORS_URL}#E9"
)
elif not field_type:
raise QuerySyntaxError("Could not resolve field type. See docs: TODO")
raise QuerySyntaxError(
f"Could not resolve field type. Docs: {ERRORS_URL}#E10"
)
elif not field_info:
raise QuerySyntaxError("Could not resolve field info. See docs: TODO")
raise QuerySyntaxError(
f"Could not resolve field info. Docs: {ERRORS_URL}#E11"
)
else:
result += self.__class__.resolve_value(
field_name,
Expand Down Expand Up @@ -3406,13 +3412,13 @@ def schema_for_type(
elif parent_is_container_type or parent_is_model_in_container:
if typ is not str:
raise RedisModelError(
"In this Preview release, list and tuple fields can only "
f"contain strings. Problem field: {name}. See docs: TODO"
"List and tuple fields can only contain strings. "
f"Problem field: {name}. Docs: {ERRORS_URL}#E12"
)
if full_text_search is True:
raise RedisModelError(
"List and tuple fields cannot be indexed for full-text "
f"search. Problem field: {name}. See docs: TODO"
f"search. Problem field: {name}. Docs: {ERRORS_URL}#E13"
)
# List/tuple fields are indexed as TAG fields and can be sortable
schema = f"{path} AS {index_field_name} TAG SEPARATOR {SINGLE_VALUE_TAG_FIELD_SEPARATOR}"
Expand Down
60 changes: 60 additions & 0 deletions docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,63 @@ Member.find(Member.first_name != "Andrew").all()

Still, `~` is useful to negate groups of expressions
surrounded by parentheses.

## E9

> Could not resolve field name.

Redis OM encountered a query expression where it could not determine the field name. This usually indicates a malformed query. Make sure your query starts with a model field, like `Model.field_name == value`.

## E10

> Could not resolve field type.

Redis OM could not determine the type of a field in your query. This might happen if the field annotation is missing or invalid. Ensure your model fields have proper type annotations.

## E11

> Could not resolve field info.

Redis OM could not find field metadata for a field in your query. This is an internal error that shouldn't normally occur. If you see this, please file an issue on GitHub.

## E12

> List and tuple fields can only contain strings.

When indexing a `List` or `Tuple` field in a JsonModel, the elements must be strings. For example:

```python
from typing import List
from redis_om import JsonModel, Field

# This works - list of strings
class Article(JsonModel):
tags: List[str] = Field(index=True)

# This does NOT work - list of integers
class Article(JsonModel):
scores: List[int] = Field(index=True) # Raises E12
```

If you need to store lists of other types, you can still do so without indexing them.

## E13

> List and tuple fields cannot be indexed for full-text search.

You cannot use `full_text_search=True` on a `List` or `Tuple` field. List fields are indexed as TAG fields, which support exact matching but not full-text search.

```python
from typing import List
from redis_om import JsonModel, Field

# This works - list with regular indexing
class Article(JsonModel):
tags: List[str] = Field(index=True)

# This does NOT work - list with full-text search
class Article(JsonModel):
tags: List[str] = Field(index=True, full_text_search=True) # Raises E13
```

If you need full-text search, use a regular string field instead.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ packages = [
{ "include" = "redis_om" },
]
classifiers = [
"Development Status :: 3 - Alpha",
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
Expand Down
Loading