Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR unknown command 'JSON.SET'

569 views Asked by At

I am using redis-om and Java, I get Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR unknown command 'JSON.SET'

Here is the code that I am using:

@SpringBootApplication
@Configuration
@EnableRedisDocumentRepositories(basePackages = "jphaugla.redisom.com.romsdocuments.*")
public class RomsDocumentsApplication {

    @Autowired
    CompanyRepository companyRepo;

    @Bean
    CommandLineRunner loadTestData() {
        return args -> {
            Company redis = Company.of("https://redis.com", new Point(-122.066540, 37.377690), 526,
                    2011, "Redis", "Salavatore Sanfilippo");
            redis.setTags(Set.of("fast", "scalable", "reliable"));

            companyRepo.save(redis);
        };
    }

    public static void main(String[] args) {
        SpringApplication.run(RomsDocumentsApplication.class, args);
    }

}

and It is dependency in my pom.xml:

<dependency>
            <groupId>com.redis.om</groupId>
            <artifactId>redis-om-spring</artifactId>
            <version>0.6.3</version>
        </dependency>

and for more information , I add my document here :

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;

@Data
@RequiredArgsConstructor(staticName = "of")
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@Document
public class Company {
  @Id
  private String id;
  @Indexed
  private Set<String> tags = new HashSet<String>();
  @NonNull
  private String url;
  @NonNull
  @Indexed
  private Point location;
  @NonNull
  @Indexed
  private Integer numberOfEmployees;
  @NonNull
  @Indexed
  private Integer yearFounded;
  @NonNull
  @Searchable
  private String name;
  @Searchable
  @NonNull
  private String founder;
  private boolean publiclyListed;
}

Java version is 17 ,spring boot version is 2.7.5 , image of Redis : image: "redis/redis-stack:7.2.0-v1"

P.S:I have checked that I had the ReJson module on my Redis and also I am able to call Json.set on my Redis-Cli.

1

There are 1 answers

2
Simon Prickett On

I suspect your code is pointed at a local Redis instance that doesn't have the JSON module installed. Note you'll want BOTH of the JSON and Search modules installed to use Redis OM successfully or you can use Redis Stack that has them installed for you.

To configure your Redis OM application to point at a different Redis instance. Do so like this in application.properties:

spring.data.redis.host=your.cloud.db.redislabs.com                                                                                                                                                                                                                    
spring.data.redis.port=12345
spring.data.redis.password=xxxxxxxx
spring.data.redis.username=default

Source: https://github.com/redis/redis-om-spring#configuring-your-redis-connection

Redis Stack (easy way to get the modules): https://redis.io/docs/getting-started/install-stack/