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
12 changes: 6 additions & 6 deletions docs/overview/cli.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"12:42:18 [RedisVL] INFO RedisVL version 0.8.0\n"
"11:20:38 [RedisVL] INFO RedisVL version 0.8.2\n"
]
}
],
Expand Down Expand Up @@ -300,7 +300,7 @@
"\n",
"| Argument | Description | Default |\n",
"|----------------|-------------|---------|\n",
"| `-u --url` | The full Redis URL to connec to | `redis://localhost:6379` |\n",
"| `-u --url` | The full Redis URL to connect to | `redis://localhost:6379` |\n",
"| `--host` | Redis host to connect to | `localhost` |\n",
"| `-p --port` | Redis port to connect to. Must be an integer | `6379` |\n",
"| `--user` | Redis username, if one is required | `default` |\n",
Expand Down Expand Up @@ -339,8 +339,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Using SSL encription\n",
"If your Redis instance is configured to use SSL encription then set the `--ssl` flag.\n",
"### Using SSL encryption\n",
"If your Redis instance is configured to use SSL encryption then set the `--ssl` flag.\n",
"You can similarly specify the username and password to construct the full Redis URL"
]
},
Expand Down Expand Up @@ -374,7 +374,7 @@
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": "redisvl-56gG2io_-py3.11",
"language": "python",
"name": "python3"
},
Expand All @@ -388,7 +388,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.2"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "redisvl"
version = "0.8.1"
version = "0.8.2"
description = "Python client library and CLI for using Redis as a vector database"
authors = [{ name = "Redis Inc.", email = "applied.ai@redis.com" }]
requires-python = ">=3.9,<3.14"
Expand Down
2 changes: 0 additions & 2 deletions redisvl/query/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,8 +939,6 @@ def _build_query_string(self) -> str:
filter_expression = self._filter_expression
if isinstance(filter_expression, FilterExpression):
filter_expression = str(filter_expression)
else:
filter_expression = ""

text = (
f"@{self._text_field_name}:({self._tokenize_and_escape_query(self._text)})"
Expand Down
2 changes: 1 addition & 1 deletion redisvl/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.8.0"
__version__ = "0.8.2"
68 changes: 68 additions & 0 deletions tests/unit/test_query_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,74 @@ def test_text_query():
text_query = TextQuery(text_string, text_field_name, stopwords=[1, 2, 3])


def test_text_query_with_string_filter():
"""Test that TextQuery correctly includes string filter expressions in query string.

This test ensures that when a string filter expression is passed to TextQuery,
it's properly included in the generated query string and not set to empty.
Regression test for bug where string filters were being ignored.
"""
text = "search for document 12345"
text_field_name = "description"

# Test with string filter expression - should include filter in query string
string_filter = "@category:{tech|science|engineering}"
text_query = TextQuery(
text=text,
text_field_name=text_field_name,
filter_expression=string_filter,
)

# Check that filter is stored correctly
assert text_query.filter == string_filter

# Check that the generated query string includes both text search and filter
query_string = str(text_query)
assert f"@{text_field_name}:(search | document | 12345)" in query_string
assert f"AND {string_filter}" in query_string
assert string_filter in query_string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this second assertion seems redundant.


# Test with FilterExpression - should also work (existing functionality)
filter_expression = Tag("category") == "tech"
text_query_with_filter_expr = TextQuery(
text=text,
text_field_name=text_field_name,
filter_expression=filter_expression,
)

# Check that filter is stored correctly
assert text_query_with_filter_expr.filter == filter_expression

# Check that the generated query string includes both text search and filter
query_string_with_filter_expr = str(text_query_with_filter_expr)
assert (
f"@{text_field_name}:(search | document | 12345)"
in query_string_with_filter_expr
)
assert "AND @category:{tech}" in query_string_with_filter_expr

# Test with no filter - should only have text search
text_query_no_filter = TextQuery(
text=text,
text_field_name=text_field_name,
)

query_string_no_filter = str(text_query_no_filter)
assert f"@{text_field_name}:(search | document | 12345)" in query_string_no_filter
assert "AND" not in query_string_no_filter

# Test with wildcard filter - should only have text search (no AND clause)
text_query_wildcard = TextQuery(
text=text,
text_field_name=text_field_name,
filter_expression="*",
)

query_string_wildcard = str(text_query_wildcard)
assert f"@{text_field_name}:(search | document | 12345)" in query_string_wildcard
assert "AND" not in query_string_wildcard


@pytest.mark.parametrize(
"query",
[
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading