(self, client)
| 1227 | @pytest.mark.redismod |
| 1228 | @skip_ifmodversion_lt("2.2.0", "search") |
| 1229 | def test_fields_as_name(self, client): |
| 1230 | # create index |
| 1231 | SCHEMA = ( |
| 1232 | TextField("$.name", sortable=True, as_name="name"), |
| 1233 | NumericField("$.age", as_name="just_a_number"), |
| 1234 | ) |
| 1235 | definition = IndexDefinition(index_type=IndexType.JSON) |
| 1236 | client.ft().create_index(SCHEMA, definition=definition) |
| 1237 | |
| 1238 | # insert json data |
| 1239 | res = client.json().set("doc:1", Path.root_path(), {"name": "Jon", "age": 25}) |
| 1240 | assert res |
| 1241 | |
| 1242 | res = client.ft().search(Query("Jon").return_fields("name", "just_a_number")) |
| 1243 | if expects_resp2_shape(client) or expects_unified_shape(client): |
| 1244 | assert 1 == len(res.docs) |
| 1245 | assert "doc:1" == res.docs[0].id |
| 1246 | assert "Jon" == res.docs[0].name |
| 1247 | assert "25" == res.docs[0].just_a_number |
| 1248 | elif expects_resp3_shape(client): |
| 1249 | assert 1 == len(res["results"]) |
| 1250 | assert "doc:1" == res["results"][0]["id"] |
| 1251 | assert "Jon" == res["results"][0]["extra_attributes"]["name"] |
| 1252 | assert "25" == res["results"][0]["extra_attributes"]["just_a_number"] |
| 1253 | |
| 1254 | @pytest.mark.redismod |
| 1255 | def test_casesensitive(self, client): |
nothing calls this directly
no test coverage detected