|
@@ -2,6 +2,7 @@ import ch.qos.logback.classic.Level;
|
|
|
import ch.qos.logback.classic.Logger;
|
|
import ch.qos.logback.classic.Logger;
|
|
|
import ch.qos.logback.classic.LoggerContext;
|
|
import ch.qos.logback.classic.LoggerContext;
|
|
|
import cn.reghao.jutil.tool.id.SnowFlake;
|
|
import cn.reghao.jutil.tool.id.SnowFlake;
|
|
|
|
|
+import cn.reghao.tnb.content.api.constant.PostScope;
|
|
|
import cn.reghao.tnb.search.api.dto.VideoSummary;
|
|
import cn.reghao.tnb.search.api.dto.VideoSummary;
|
|
|
import cn.reghao.tnb.search.app.SearchApplication;
|
|
import cn.reghao.tnb.search.app.SearchApplication;
|
|
|
import cn.reghao.tnb.search.app.es.*;
|
|
import cn.reghao.tnb.search.app.es.*;
|
|
@@ -12,7 +13,11 @@ import cn.reghao.tnb.search.app.model.po.VideoText;
|
|
|
import cn.reghao.tnb.search.app.model.po.Wenshu;
|
|
import cn.reghao.tnb.search.app.model.po.Wenshu;
|
|
|
import cn.reghao.tnb.search.app.util.ClassUtil;
|
|
import cn.reghao.tnb.search.app.util.ClassUtil;
|
|
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|
|
|
|
+import co.elastic.clients.elasticsearch._types.FieldValue;
|
|
|
import co.elastic.clients.elasticsearch._types.mapping.Property;
|
|
import co.elastic.clients.elasticsearch._types.mapping.Property;
|
|
|
|
|
+import co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery;
|
|
|
|
|
+import co.elastic.clients.elasticsearch._types.query_dsl.Query;
|
|
|
|
|
+import co.elastic.clients.elasticsearch._types.query_dsl.QueryStringQuery;
|
|
|
import co.elastic.clients.elasticsearch.indices.AnalyzeRequest;
|
|
import co.elastic.clients.elasticsearch.indices.AnalyzeRequest;
|
|
|
import co.elastic.clients.elasticsearch.indices.AnalyzeResponse;
|
|
import co.elastic.clients.elasticsearch.indices.AnalyzeResponse;
|
|
|
import co.elastic.clients.elasticsearch.indices.analyze.AnalyzeToken;
|
|
import co.elastic.clients.elasticsearch.indices.analyze.AnalyzeToken;
|
|
@@ -179,6 +184,7 @@ public class SearchTest {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Test
|
|
|
public void queryTest() {
|
|
public void queryTest() {
|
|
|
setLogLevel();
|
|
setLogLevel();
|
|
|
|
|
|
|
@@ -190,9 +196,6 @@ public class SearchTest {
|
|
|
pn++;
|
|
pn++;
|
|
|
page = queryService.queryWithHighlight(index, queryString, pn, ps, Wenshu.class);
|
|
page = queryService.queryWithHighlight(index, queryString, pn, ps, Wenshu.class);
|
|
|
}*/
|
|
}*/
|
|
|
-
|
|
|
|
|
- System.out.println();
|
|
|
|
|
-
|
|
|
|
|
Page<Wenshu> page = queryService.queryWithHighlight(index, queryString, pn, ps, Wenshu.class);
|
|
Page<Wenshu> page = queryService.queryWithHighlight(index, queryString, pn, ps, Wenshu.class);
|
|
|
long total = page.getTotalElements();
|
|
long total = page.getTotalElements();
|
|
|
int totalPages = page.getTotalPages();
|
|
int totalPages = page.getTotalPages();
|
|
@@ -200,7 +203,9 @@ public class SearchTest {
|
|
|
page = queryService.queryWithHighlight(index, queryString, pn, ps, Wenshu.class);
|
|
page = queryService.queryWithHighlight(index, queryString, pn, ps, Wenshu.class);
|
|
|
List<Wenshu> list = page.getContent();
|
|
List<Wenshu> list = page.getContent();
|
|
|
Wenshu wenshu = list.get(0);
|
|
Wenshu wenshu = list.get(0);
|
|
|
- Wenshu wenshu1 = queryService.queryById(Wenshu.class, index, wenshu.getId());
|
|
|
|
|
|
|
+ String id = wenshu.getId();
|
|
|
|
|
+ String caseName = wenshu.getCaseName();
|
|
|
|
|
+ System.out.println(caseName);
|
|
|
pn++;
|
|
pn++;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -212,8 +217,6 @@ public class SearchTest {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
LuceneDocument luceneDocument;
|
|
LuceneDocument luceneDocument;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- QueryService<VideoSummary> esQuery;
|
|
|
|
|
- @Autowired
|
|
|
|
|
SearchService searchService;
|
|
SearchService searchService;
|
|
|
@Test
|
|
@Test
|
|
|
public void storeTest() throws Exception {
|
|
public void storeTest() throws Exception {
|
|
@@ -242,17 +245,33 @@ public class SearchTest {
|
|
|
//Page<VideoSummary> page2 = esQuery.queryWithHighlight(index, kw, pn, ps, VideoSummary.class);
|
|
//Page<VideoSummary> page2 = esQuery.queryWithHighlight(index, kw, pn, ps, VideoSummary.class);
|
|
|
System.out.println();
|
|
System.out.println();
|
|
|
|
|
|
|
|
- Map<String, Property> propertyMap = mappingService.getVideoTextPropertyMap();
|
|
|
|
|
|
|
+ //Map<String, Property> propertyMap = mappingService.getVideoTextPropertyMap();
|
|
|
// indexService.deleteIndex(index);
|
|
// indexService.deleteIndex(index);
|
|
|
// indexService.createIndex(index, propertyMap);
|
|
// indexService.createIndex(index, propertyMap);
|
|
|
//indexService.getIndex(index);
|
|
//indexService.getIndex(index);
|
|
|
- indexService.deleteIndex(index);
|
|
|
|
|
|
|
+ //indexService.deleteIndex(index);
|
|
|
//indexService.getIndex(index);
|
|
//indexService.getIndex(index);
|
|
|
//indexService.updateMapping(index);
|
|
//indexService.updateMapping(index);
|
|
|
//searchService.searchAll(index);
|
|
//searchService.searchAll(index);
|
|
|
//searchService.count(index);
|
|
//searchService.count(index);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ VideoTextQuery videoTextQuery;
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void searchTest() {
|
|
|
|
|
+ int pn = 1;
|
|
|
|
|
+ int ps = 1000;
|
|
|
|
|
+ String keyword = "大奶";
|
|
|
|
|
+
|
|
|
|
|
+ List<Integer> scopes = List.of(PostScope.PUBLIC.getCode(), PostScope.PROTECT.getCode());
|
|
|
|
|
+ Page<VideoText> page = videoTextQuery.queryWithHighlight(keyword, scopes, pn, ps);
|
|
|
|
|
+ //Page<VideoText> page1 = esQuery.queryByPage(index, "query", pn, ps, VideoText.class);
|
|
|
|
|
+ long total = page.getTotalElements();
|
|
|
|
|
+ List<VideoText> list = page.getContent();
|
|
|
|
|
+ System.out.println();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Test
|
|
@Test
|
|
|
public void analyzerTest() throws IOException {
|
|
public void analyzerTest() throws IOException {
|
|
|
String text = "中华人民共和国国歌";
|
|
String text = "中华人民共和国国歌";
|
|
@@ -263,8 +282,11 @@ public class SearchTest {
|
|
|
.text(text)
|
|
.text(text)
|
|
|
.analyzer(analyzer)
|
|
.analyzer(analyzer)
|
|
|
.build();
|
|
.build();
|
|
|
- ElasticsearchClient esClient = elasticService.getElasticsearchClient();
|
|
|
|
|
|
|
+ /*ElasticsearchClient esClient = elasticService.getElasticsearchClient();
|
|
|
AnalyzeResponse analyzeResponse = esClient.indices().analyze(analyzeRequest);
|
|
AnalyzeResponse analyzeResponse = esClient.indices().analyze(analyzeRequest);
|
|
|
- List<AnalyzeToken> tokens = analyzeResponse.tokens();
|
|
|
|
|
|
|
+ List<AnalyzeToken> tokens = analyzeResponse.tokens();*/
|
|
|
|
|
+
|
|
|
|
|
+ String index = "videotext";
|
|
|
|
|
+ documentService.deleteAllDocument(index);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|