Back to Redis

Search Active Active

content/operate/oss_and_stack/stack-with-enterprise/search/search-active-active.md

latest2.6 KB
Original Source

Starting with RediSearch 2.x, supported in Redis Software (RS) 6.0 and later, you can [enable search and query]({{< relref "/operate/oss_and_stack/stack-with-enterprise/install/add-module-to-database" >}}) for [Active-Active databases]({{< relref "/operate/rs/databases/active-active" >}}) at the time of creation.

You can run search operations on any instance of an Active-Active database.

How it works

  1. Create an Active-Active database with RediSearch 2.x enabled. Active-Active databases created with or upgraded to Redis version 8 or later automatically enable search and query.
  2. [Create the index]({{< relref "commands/ft.create" >}}) on each instance of the database.
  3. If you are using [synonyms]({{< relref "/develop/ai/search-and-query/advanced-concepts/synonyms" >}}), you need to add them to each replica.
  4. The index is maintained by each instance outside of the database keyspace, so only updates to the hashes in the databases are synchronized.

Command compatibility

Active-Active databases do not support the following search and query commands:

  • [FT.DROPINDEX ]({{< relref "commands/ft.dropindex" >}})
  • [FT.SUGADD]({{< relref "commands/ft.sugadd" >}})
  • [FT.SUGGET]({{< relref "commands/ft.sugget" >}})
  • [FT.SUGDEL]({{< relref "commands/ft.sugdel" >}})
  • [FT.SUGLEN]({{< relref "commands/ft.suglen" >}})

Example

Here's an example to help visualize Active-Active search and query:

TimeDescriptionCRDB Instance1RediSearch Instance 1CRDB Instance 2RediSearch Instance 2
t0Create the index on each instanceFT.CREATE idx ....FT.CREATE idx ....
t1Add doc1 as a hash on instance 1; RediSearch indexes doc1 on instance 1HSET doc1 field1 "a"(Index doc1 field1 "a")
t2Add doc2 as a hash on instance 2; RediSearch indexes doc2 on instance 2HSET doc1 field2 "b"(Index doc1 field2 "b")
t3Searching for "a" in each instance only finds the result in instance 1FT.Search idx "a"
  1. 1
  2. doc1 | | FT.Search idx "a"
  3. 0 | | t4 | Active-Active synchronization | - Sync - | | - Sync - | | | t5 | Both hashes are found in each instance | HGETALL doc1
  4. "field2"
  5. "b"
  6. "field1"
  7. "a" | | HGETALL doc1
  8. "field2"
  9. "b"
  10. "field1"
  11. "a" | | | t6 | Searching for "a" in each instance finds both documents | | FT.Search idx "a"
  12. 1
  13. doc1 | | FT.Search idx "a"
  14. 1
  15. doc1 |

The practical result is that you have a geo-distributed database with a high level of consistency that can also run search operations on any instance.