|
@@ -76,7 +76,23 @@ public class SearchClientTest {
|
|
|
// QueryBuilder timeClause = QueryBuilders.rangeQuery("logtime.keyword").from(startTime).to(endTime);
|
|
|
// QueryBuilder queryBuilder = QueryBuilders.matchQuery("logclass.keyword", "com.huohuo.Test");
|
|
|
// and/or/not等:涉及到多条件查询用boolQuery,组合多个query。must表示and,mustNot表示not,should表示or。
|
|
|
+ }
|
|
|
|
|
|
+ @Test
|
|
|
+ public void multiMatchTest() {
|
|
|
+ SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
+ QueryBuilder queryBuilder = QueryBuilders.multiMatchQuery("黄湘豫想进行驾照考试", "author", "name");
|
|
|
+ searchSourceBuilder.query(queryBuilder);
|
|
|
+ String query = searchSourceBuilder.toString();
|
|
|
+ Search search = new Search.Builder(query)
|
|
|
+ .addIndex("t_paper")
|
|
|
+ .build();
|
|
|
+ try {
|
|
|
+ SearchResult result = jestClient.execute(search);
|
|
|
+ System.out.println(result.getJsonString());
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|