Redis throwing an key error when inserting - Jedis

24 views Asked by At

Im trying to setup a search index on redis and index products into it.. It throws an error while setting the value in redis Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: Existing key has wrong Redis type

        JedisPooled client = new JedisPooled(redisHost, redisPort);
        try {
            client.ftDropIndex("idx:product");
        } catch (JedisDataException e) {
            // ignore
        }
        SchemaField[] schema = {
        TextField.of("$.id").as("id"),
        TextField.of("$.name").as("name"),
        TagField.of("$.category").as("category"),
        TagField.of("$.color").as("color")};


         client.ftCreate("idx:product",
                FTCreateParams.createParams()
                        .on(IndexDataType.JSON)
                        .addPrefix("product:"),
                schema
        );

 client.jsonSetWithEscape(String.format("product:%s", product.getId()), product);

`Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: Existing key has wrong Redis type
`
0

There are 0 answers