作者 王勇

ES相关接口,基本完善

... ... @@ -3,7 +3,7 @@ target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
*.log
### STS ###
.apt_generated
.classpath
... ...
... ... @@ -23,7 +23,7 @@ import java.util.Date;
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "message_note")
@Document(indexName = "message")
public class MessageNote implements Serializable {
private static final long serialVersionUID = -2119333801860569470L;
... ... @@ -42,7 +42,7 @@ public class MessageNote implements Serializable {
/**
* 所属用户登陆名称
*/
@Field(type = FieldType.Text, analyzer = "ik_max_word")
@Field(type = FieldType.Keyword)
private String username;
/**
... ... @@ -54,7 +54,7 @@ public class MessageNote implements Serializable {
/**
* 所属服务器名称
*/
@Field(type = FieldType.Text, analyzer = "ik_max_word")
@Field(type = FieldType.Keyword)
private String serverName;
/**
... ... @@ -66,7 +66,7 @@ public class MessageNote implements Serializable {
/**
* 所属虚拟主机名称
*/
@Field(type = FieldType.Text, analyzer = "ik_max_word")
@Field(type = FieldType.Keyword)
private String virtualHostName;
/**
... ... @@ -78,7 +78,7 @@ public class MessageNote implements Serializable {
/**
* 所属交换机名称
*/
@Field(type = FieldType.Text, analyzer = "ik_max_word")
@Field(type = FieldType.Keyword)
private String exchangeName;
/**
... ... @@ -90,7 +90,7 @@ public class MessageNote implements Serializable {
/**
* 所属队列名称
*/
@Field(type = FieldType.Text, analyzer = "ik_max_word")
@Field(type = FieldType.Keyword)
private String queueName;
/**
... ... @@ -102,7 +102,7 @@ public class MessageNote implements Serializable {
/**
* 所属路由键的名称
*/
@Field(type = FieldType.Text, analyzer = "ik_max_word")
@Field(type = FieldType.Keyword)
private String routingKeyName;
/**
... ... @@ -141,7 +141,7 @@ public class MessageNote implements Serializable {
/**
* 发送消息内容,别名
*/
@Field(type = FieldType.Text, analyzer = "ik_max_word")
@Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_max_word")
private String alias_sendContent;
/**
... ...
... ... @@ -51,7 +51,7 @@ public class ElasticsearchService {
public ResultJson selectMessageNoteList(MessageNote messageNote, Integer pageNum, Integer pageSize) throws IOException
{
// 条件搜索
SearchRequest searchRequest = new SearchRequest("message_note");
SearchRequest searchRequest = new SearchRequest("message");
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
// 高亮设置
... ... @@ -109,7 +109,8 @@ public class ElasticsearchService {
boolQueryBuilder.must(routingKeyNameQuery);
}
if (!StringUtil.isNullOrEmpty(messageNote.getAlias_sendContent())) {
WildcardQueryBuilder sendContentQuery = QueryBuilders.wildcardQuery("alias_sendContent", messageNote.getAlias_sendContent());
String content = messageNote.getAlias_sendContent();
WildcardQueryBuilder sendContentQuery = QueryBuilders.wildcardQuery("alias_sendContent", content.matches(".*[a-zA-z].*") ? content.toLowerCase() : content);
boolQueryBuilder.must(sendContentQuery);
}
if (messageNote.getSendTimeBegin() != null && messageNote.getSendTimeEnd() != null) {
... ...