新增模块
parent
6eb2f5f7e1
commit
822b766890
@ -0,0 +1,33 @@
|
|||||||
|
package com.supervision.knowsub.controller;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import org.springframework.ai.document.Document;
|
||||||
|
import org.springframework.ai.vectorstore.ElasticsearchVectorStore;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("esTest")
|
||||||
|
public class EsTestController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ElasticsearchVectorStore elasticsearchVectorStore;
|
||||||
|
|
||||||
|
@GetMapping("add")
|
||||||
|
public void add(){
|
||||||
|
Document document = new Document("测试测试");
|
||||||
|
elasticsearchVectorStore.add(List.of(document));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("search")
|
||||||
|
public void search(){
|
||||||
|
List<Document> result = elasticsearchVectorStore.similaritySearch("");
|
||||||
|
for (Document document : result) {
|
||||||
|
System.out.println(JSONUtil.toJsonStr(document));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue