这个快速入门将指导您设置Meilisearch、添加文档、执行第一次搜索、使用搜索预览、添加搜索栏以及保护实例。
所需的只是一个命令行(打开新窗口)进行安装,以及之后与Meilisearch交互的某种方式(例如,cURL(打开新的窗口)或我们的一个SDK)。
让我们开始吧!
#设置和安装
我们将从下载和安装Meilisearch开始。您可以选择在本地安装Meilisearch或通过云服务部署它。

Meilisearch helps you shape a delightful search experience in a snap, offering features that work out-of-the-box to speed up your workflow.
在这里插入图片描述

参考:https://github.com/meilisearch/meilisearch
下载地址:https://github.com/meilisearch/Meilisearch/releases

依赖

<dependency>
  <groupId>com.meilisearch.sdk</groupId>
  <artifactId>meilisearch-java</artifactId>
  <version>0.7.2</version>
</dependency>

案例

import com.meilisearch.sdk;
import java.nio.file.Files;
import java.nio.file.Path;

Path fileName = Path.of("movies.json");
String moviesJson = Files.readString(fileName);
Client client = new Client(new Config("http://127.0.0.1:7700", "masterKey"));
Index index = client.index("movies");
index.addDocuments(moviesJson);

创建索引

client.index("movies").search("botman");

获取客户端

Client client = new Client(new Config("http://127.0.0.1:7700", "masterKey"));
client.getKeys();

查询

Client client = new Client(new Config("http://127.0.0.1:7700", "apiKey"));
client.index("movies").search(new SearchRequest(""));
Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐