Search code examples
redisspring-data-redisredis-clusterredisearchredislabs

Adding Prefix when creating an Index using Jredisearch


I use Jredisearch(com.redislabs:jredisearch:2.0.0) to store data in an Index. I want to add a prefix while creating the Index. I am able to add prefix using the below Redisearch command FT.CREATE MyIndex ON HASH PREFIX 1 doc: SCHEMA name TEXT

But not able to find options for the same when writing in Java. I use the following code in Java, client.createIndex(schema, Client.IndexOptions.defaultOptions());

Could anyone suggest how do we add Prefix when using Jredisearch?


Solution

  • IndexDefinition class has a setPrefixes(...) method which serves your purpose.

    Note: You may have to create IndexDefinition using new IndexDefinition().