(self, client)
| 1514 | @skip_if_server_version_lt("7.4.0") |
| 1515 | @skip_ifmodversion_lt("2.10.0", "search") |
| 1516 | def test_search_missing_fields(self, client): |
| 1517 | definition = IndexDefinition(prefix=["property:"], index_type=IndexType.HASH) |
| 1518 | |
| 1519 | fields = [ |
| 1520 | TextField("title", sortable=True), |
| 1521 | TagField("features", index_missing=True), |
| 1522 | TextField("description", index_missing=True), |
| 1523 | ] |
| 1524 | |
| 1525 | client.ft().create_index(fields, definition=definition) |
| 1526 | |
| 1527 | # All fields present |
| 1528 | client.hset( |
| 1529 | "property:1", |
| 1530 | mapping={ |
| 1531 | "title": "Luxury Villa in Malibu", |
| 1532 | "features": "pool,sea view,modern", |
| 1533 | "description": "A stunning modern villa overlooking the Pacific Ocean.", |
| 1534 | }, |
| 1535 | ) |
| 1536 | |
| 1537 | # Missing features |
| 1538 | client.hset( |
| 1539 | "property:2", |
| 1540 | mapping={ |
| 1541 | "title": "Downtown Flat", |
| 1542 | "description": "Modern flat in central Paris with easy access to metro.", |
| 1543 | }, |
| 1544 | ) |
| 1545 | |
| 1546 | # Missing description |
| 1547 | client.hset( |
| 1548 | "property:3", |
| 1549 | mapping={ |
| 1550 | "title": "Beachfront Bungalow", |
| 1551 | "features": "beachfront,sun deck", |
| 1552 | }, |
| 1553 | ) |
| 1554 | |
| 1555 | with pytest.raises(redis.exceptions.ResponseError): |
| 1556 | client.ft().search( |
| 1557 | Query("ismissing(@title)").return_field("id").no_content() |
| 1558 | ) |
| 1559 | |
| 1560 | res = client.ft().search( |
| 1561 | Query("ismissing(@features)").return_field("id").no_content() |
| 1562 | ) |
| 1563 | _assert_search_result(client, res, ["property:2"]) |
| 1564 | |
| 1565 | res = client.ft().search( |
| 1566 | Query("-ismissing(@features)").return_field("id").no_content() |
| 1567 | ) |
| 1568 | _assert_search_result(client, res, ["property:1", "property:3"]) |
| 1569 | |
| 1570 | res = client.ft().search( |
| 1571 | Query("ismissing(@description)").return_field("id").no_content() |
| 1572 | ) |
| 1573 | _assert_search_result(client, res, ["property:3"]) |
nothing calls this directly
no test coverage detected