1
{
  "name": "Noise-cancelling Bluetooth headphones",
  "description": "Wireless Bluetooth headphones with noise-cancelling technology",
  "connection": {
    "wireless": true,
    "type": "Bluetooth"
  },
  "price": 99.98,
  "stock": 25,
  "colors": [
    "black",
    "silver"
  ],
  "embedding": [0.87, -0.15, 0.55, 0.03]
}

I have seen this object in Redis Search documentation and I'm storing similar object with Hash format. How can I make search on if wireless true return with ft.search? I have tried this one but it gives syntax error

await this.client.ft.search(index, `@colors.wireless:"${wirelessStatus}"`);

2
  • Hashes are a flat map of name/value pairs, this example uses RedisJSON as the data has nested sub-objects and arrays. Any reason why you're using hashes? Can you post an example Redis command that creates the data structure you're using e.g. an example HSET. Commented Sep 22, 2023 at 11:47
  • I was using it to vector store value with langchain Commented Sep 26, 2023 at 8:48

1 Answer 1

0

I have resolved the issue with keyword search on hashes. The reason why I can't directly use it like below is because Redis example was storing them in JSON format but I'm storing my value in Hash format.

await this.client.ft.search(index, '@wireless:"${wirelessStatus}');

So I have updated code like this. It searches wirelessStatus keyword inside related column and I'm storing identifier inside this field to retrieve it.

await this.client.ft.search(index, '@wireless:"(${wirelessStatus})');

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.