Home > Back-end >  Elasticsearch SpringBoot integration search returns some fields (hump field) is null
Elasticsearch SpringBoot integration search returns some fields (hump field) is null

Time:09-30

Request code:
 public BaseResponse Search (String search, Integer page, Integer size) {
If (page & lt; 1) {
Page=1;
}
If (size & lt; 10) {
Size=10;
}
PageRequest PageRequest=PageRequest) of (page, size);
BoolQueryBuilder builder=QueryBuilders. BoolQuery ();
Builder. Must (QueryBuilders. MultiMatchQuery (search, "title", "content", "tags"));
Page
SearchResult=articleRepository. Search (builder, pageRequest);
Return setResultSuccess ((JSONObject) JSON. ToJSON (searchResult));
}

The response data:
 {
"Code" : 200,
"MSG", "success",
"Data" : {
"Last" : true,
"Pageable" : {
"Paged" : true,
"PageNumber" : 1,
"Offset" : 10,
"PageSize" : 10,
"Unpaged" : false,
"Sort" : {
"Unsorted" : true,
"Sorted" : false,
"Empty" : true
}
},
"Sort" : {
"Unsorted" : true,
"Sorted" : false,
"Empty" : true
},
"MaxScore" : 0.13959092,
"Content" : [
{
"CreateTime", null,
"GoodCount" : null,
"Author" : 1,
"CollectCount" : null,
"UpdateTime", null,
"Id" : 16,
"ViewCount" : null,
"Title" : "I am a test article 15,"
"Content" : "I am a test article 15,"
"CommentCount" : null,
"Tags" : "1,14,10
"},
{
"CreateTime", null,
"GoodCount" : null,
"Author" : 1,
"CollectCount" : null,
"UpdateTime", null,
"Id" : 17,
"ViewCount" : null,
"Title" : "I am a test article 16",
"Content" : "I am a test article 16",
"CommentCount" : null,
"Tags" : "1,14,10
"},
{
"CreateTime", null,
"GoodCount" : null,
"Author" : 1,
"CollectCount" : null,
"UpdateTime", null,
"Id" : 9,
"ViewCount" : null,
"Title" : "I am a test article 8,"
"Content" : "I am a test article 8,"
"CommentCount" : null,
"Tags" : "1,14,10
"},
{
"CreateTime", null,
"GoodCount" : null,
"Author" : 1,
"CollectCount" : null,
"UpdateTime", null,
"Id" : 10,
"ViewCount" : null,
"Title" : "I am a test article 9,"
"Content" : "I am a test article 9,"
"CommentCount" : null,
"Tags" : "1,14,10
"},
{
"CreateTime", null,
"GoodCount" : null,
"Author" : 1,
"CollectCount" : null,
"UpdateTime", null,
"Id" : 2,
"ViewCount" : null,
"Title" : "I am a test article 1,"
"Content" : "I am the content of the test article 1,"
"CommentCount" : null,
"Tags" : "1,14,10
"},
{
"CreateTime", null,
"GoodCount" : null,
"Author" : 1,
"CollectCount" : null,
"UpdateTime", null,
"Id" : 3,
"ViewCount" : null,
"Title" : "I am a test article no. 2,"
"Content" : "I am content of test article no. 2,"
"CommentCount" : null,
"Tags" : "1,14,10
"}
],
"Empty" : false,
"Called facets: [],
"ScrollId" : null,
"TotalElements" : 16,
"Number" : 1,
"NumberOfElements" : 6,
"Size" : 10,
"TotalPages" : 2,
"Aggregations" : null,
"First" : false
}
}

Document mapping:
 @ Document (indexName="article_latest," type="_doc", shards=3, replicas=1) 
Public class Article {

@ Id
private Integer id;
@ Field (name="title", type=FieldType. Text, analyzer="ik_max_word searchAnalyzer=" ik_max_word ")
private String title;
@ Field (name="content", type=FieldType. Text, analyzer="ik_max_word searchAnalyzer=" ik_max_word ")
private String content;
@ Field (name="author", type=FieldType. Long)
Private Integer author;
@ Field (name="comment_count", type=FieldType. Long)
Private Integer commentCount;
@ Field (name="view_count," type=FieldType. Long)
Private Integer viewCount;
@ Field (name="good_count," type=FieldType. Long)
Private Integer goodCount;
@ Field (name="collect_count," type=FieldType. Long)
Private Integer collectCount;
@ Field (name="tags", type=FieldType. Text)
Private String tags.
@ Field (name="create_time", type=FieldType. Long)
Private Long createTime;
@ Field (name="update_time", type=FieldType. Long)
Private Long updateTime;

//is omitted the get/set/toString method
}

All other fields, only the hump field is null, the document I have done the mapping, but useless, ES has a hump field configuration

CodePudding user response:

Only hump field problems and change the hump fields to underline is solved, but looking at very comfortable
  • Related