24 Kasım 2021 Çarşamba

RediSearch Sınıfı

Maven
Şu satırı dahil ederiz
<dependency>
  <groupId>com.redislabs</groupId>
  <artifactId>jredisearch</artifactId>
  <version>2.0.0</version>
</dependency>
createIndex metodu
Şöyle yaparız
import io.redisearch.Schema;
import io.redisearch.client.Client;
import io.redisearch.client.IndexDefinition;
import redis.clients.jedis.Jedis;

JedisPool pool = ...;
Client redisearch = = new Client"tweets-index",pool);

 Schema sc = new Schema()
  .addTextField"id", 1.0)
  .addTextField("user", 1.0)
  .addTextField("text", 1.0)
  .addTextField("location", 1.0)
  .addTagField("hashtags");

IndexDefinition def = new IndexDefinition()
  .setPrefixes(new String[] { "tweet:" });

boolean indexCreated = redisearch
  .createIndex(sc, 
               Client.IndexOptions.defaultOptions().setDefinition(def));

redisearch.close();



Hiç yorum yok:

Yorum Gönder