|
|
package com.yoho.datasync.fullsync.service.impl;
|
|
|
import org.elasticsearch.script.Script;
|
|
|
import org.elasticsearch.tasks.TaskId;
|
|
|
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
...
|
...
|
@@ -6,12 +9,15 @@ import org.elasticsearch.action.delete.DeleteRequest; |
|
|
import org.elasticsearch.action.delete.DeleteResponse;
|
|
|
import org.elasticsearch.action.search.SearchRequest;
|
|
|
import org.elasticsearch.action.search.SearchResponse;
|
|
|
import org.elasticsearch.action.update.UpdateRequest;
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
import org.elasticsearch.index.query.QueryBuilder;
|
|
|
import org.elasticsearch.index.query.QueryBuilders;
|
|
|
import org.elasticsearch.index.reindex.BulkByScrollResponse;
|
|
|
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
|
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
|
|
import org.elasticsearch.search.sort.SortBuilders;
|
|
|
import org.elasticsearch.search.sort.SortOrder;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import com.yoho.datasync.fullsync.dal.repository.yhcommunity.model.UserInfo;
|
...
|
...
|
@@ -77,7 +83,7 @@ public class UserInfoDataSyncServiceImpl { |
|
|
result = String.valueOf(userInfoList.get(userInfoList.size()-1).getYoho_uid());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
logger.info("sync userInfo success, result uid is {}", result);
|
|
|
return result;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -123,10 +129,14 @@ public class UserInfoDataSyncServiceImpl { |
|
|
}
|
|
|
}
|
|
|
|
|
|
public String searchAllUserData(){
|
|
|
public String searchAllUserData(String keyword){
|
|
|
try {
|
|
|
BoolQueryBuilder queryBuilder = new BoolQueryBuilder();
|
|
|
queryBuilder.must(QueryBuilders.matchAllQuery());
|
|
|
// queryBuilder.must(QueryBuilders.matchAllQuery());
|
|
|
queryBuilder.should(QueryBuilders.wildcardQuery("nick_name.keyword",keyword).boost(3));
|
|
|
queryBuilder.should(QueryBuilders.wildcardQuery("nick_name.keyword",keyword+"*").boost(2));
|
|
|
queryBuilder.should(QueryBuilders.wildcardQuery("nick_name.keyword","*"+keyword+"*").boost(1));
|
|
|
queryBuilder.should(QueryBuilders.wildcardQuery("nick_name","*"+keyword+"*").boost(1));
|
|
|
|
|
|
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
|
|
|
sourceBuilder.query(queryBuilder);
|
...
|
...
|
@@ -138,7 +148,7 @@ public class UserInfoDataSyncServiceImpl { |
|
|
|
|
|
SearchResponse response = rhlClient.search(searchRequest, RequestOptions.DEFAULT);
|
|
|
logger.info("searchAllUserData: {}" , JSON.toJSONString(response));
|
|
|
return JSON.toJSONString(response.getHits().totalHits);
|
|
|
return JSON.toJSONString(response.getHits().getHits());
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
...
|
...
|
|