本文整理汇总了Java中org.sunbird.common.ElasticSearchUtil.complexSearch方法的典型用法代码示例。如果您正苦于以下问题:Java ElasticSearchUtil.complexSearch方法的具体用法?Java ElasticSearchUtil.complexSearch怎么用?Java ElasticSearchUtil.complexSearch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sunbird.common.ElasticSearchUtil
的用法示例。
在下文中一共展示了ElasticSearchUtil.complexSearch方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateHashTagId
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
private String validateHashTagId(String hashTagId,String opType,String id) {
Map<String,Object> filters = new HashMap<>();
filters.put(JsonKey.HASHTAGID, hashTagId);
SearchDTO searchDto = new SearchDTO();
searchDto.getAdditionalProperties().put(JsonKey.FILTERS,filters);
Map<String, Object> result = ElasticSearchUtil.complexSearch(searchDto,
ProjectUtil.EsIndex.sunbird.getIndexName(), ProjectUtil.EsType.course.getTypeName());
List<Map<String, Object>> dataMapList =
(List<Map<String, Object>>) result.get(JsonKey.CONTENT);
if(opType.equalsIgnoreCase(JsonKey.CREATE)){
if(!dataMapList.isEmpty()){
throw new ProjectCommonException(ResponseCode.invalidHashTagId.getErrorCode(),
ResponseCode.invalidHashTagId.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
}
}else if(opType.equalsIgnoreCase(JsonKey.UPDATE) && !dataMapList.isEmpty()){
Map<String, Object> batchMap = dataMapList.get(0);
if(!(((String)batchMap.get(JsonKey.ID)).equalsIgnoreCase(id))){
throw new ProjectCommonException(ResponseCode.invalidHashTagId.getErrorCode(),
ResponseCode.invalidHashTagId.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
}
}
return hashTagId;
}
示例2: validateHashTagId
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
private String validateHashTagId(String hashTagId,String opType,String orgId) {
Map<String,Object> filters = new HashMap<>();
filters.put(JsonKey.HASHTAGID, hashTagId);
SearchDTO searchDto = new SearchDTO();
searchDto.getAdditionalProperties().put(JsonKey.FILTERS,filters);
Map<String, Object> result = ElasticSearchUtil.complexSearch(searchDto,
ProjectUtil.EsIndex.sunbird.getIndexName(), ProjectUtil.EsType.organisation.getTypeName());
List<Map<String, Object>> dataMapList =
(List<Map<String, Object>>) result.get(JsonKey.CONTENT);
if(opType.equalsIgnoreCase(JsonKey.CREATE)){
if(!dataMapList.isEmpty()){
throw new ProjectCommonException(ResponseCode.invalidHashTagId.getErrorCode(),
ResponseCode.invalidHashTagId.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
}
}else if(opType.equalsIgnoreCase(JsonKey.UPDATE) && !dataMapList.isEmpty()){
Map<String, Object> orgMap = dataMapList.get(0);
if(!(((String)orgMap.get(JsonKey.ID)).equalsIgnoreCase(orgId))){
throw new ProjectCommonException(ResponseCode.invalidHashTagId.getErrorCode(),
ResponseCode.invalidHashTagId.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
}
}
return hashTagId;
}
示例3: getOrgsData
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
/**
* @param actorMessage
*/
private Map<String, Object> getOrgsData(Request actorMessage) {
Map<String, Object> requestMap = actorMessage.getRequest();
SearchDTO dto = new SearchDTO();
Map<String, Object> map = new HashMap<String, Object>();
// TODO need to check with request body what data we will get
// map.put(JsonKey.REGISTERED_ORG_ID, "some value");
// map.put(JsonKey.ROOT_ORG_ID, "");
Map<String, Object> additionalProperty = new HashMap<>();
additionalProperty.put(JsonKey.FILTERS, map);
dto.setAdditionalProperties(additionalProperty);
Map<String, Object> responseMap = ElasticSearchUtil.complexSearch(dto,
ProjectUtil.EsIndex.sunbird.getIndexName(), ProjectUtil.EsType.organisation.getTypeName());
if (requestMap != null) {
return responseMap;
}
return null;
}
示例4: getUserDetails
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
/**
* @param actorMessage
*/
private void getUserDetails(Request actorMessage) {
Map<String, Object> requestMap = actorMessage.getRequest();
SearchDTO dto = new SearchDTO();
Map<String, Object> map = new HashMap<>();
map.put(JsonKey.REGISTERED_ORG_ID, requestMap.get(JsonKey.REGISTERED_ORG_ID));
map.put(JsonKey.ROOT_ORG_ID, requestMap.get(JsonKey.ROOT_ORG_ID));
Map<String, Object> additionalProperty = new HashMap<>();
additionalProperty.put(JsonKey.FILTERS, map);
dto.setAdditionalProperties(additionalProperty);
Map<String, Object> responseMap = ElasticSearchUtil.complexSearch(dto,
ProjectUtil.EsIndex.sunbird.getIndexName(), ProjectUtil.EsType.user.getTypeName());
Response response = new Response();
response.put(JsonKey.RESPONSE, responseMap);
sender().tell(response, self());
}
示例5: getUserDetailsFromES
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private List<Map<String, Object>> getUserDetailsFromES(List<Map<String, Object>> ekstepData) {
List<String> coursefields = new ArrayList<>();
List<Map<String, Object>> userResult = new ArrayList<>();
coursefields.add(JsonKey.USER_ID);
coursefields.add(JsonKey.USERNAME);
coursefields.add(JsonKey.CREATED_DATE);
String userId = "";
for (Map<String, Object> userData : ekstepData) {
Map<String, Object> data = new HashMap<>();
if (userData.containsKey("userId")) {
userId = (String) userData.get("userId");
} else {
return ekstepData;
}
Map<String, Object> filter = new HashMap<>();
filter.put(JsonKey.IDENTIFIER, userId);
try {
Map<String, Object> result =
ElasticSearchUtil.complexSearch(createESRequest(filter, null, coursefields),
ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.user.getTypeName());
if (null != result && !result.isEmpty()) {
List<Map<String, Object>> resultList =
(List<Map<String, Object>>) result.get(JsonKey.CONTENT);
if (null != resultList && !resultList.isEmpty()) {
for (Map<String, Object> dataObject : resultList) {
data.putAll(dataObject);
}
}
data.putAll(userData);
userResult.add(data);
}
} catch (Exception e) {
throw new ProjectCommonException(ResponseCode.esError.getErrorCode(),
ResponseCode.esError.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode());
}
}
return userResult;
}
示例6: getUserDetailsUsingOrg
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private List<Map<String, Object>> getUserDetailsUsingOrg(String orgId) {
List<String> coursefields = new ArrayList<>();
List<Map<String, Object>> userResult = new ArrayList<>();
coursefields.add(JsonKey.USER_ID);
coursefields.add(JsonKey.USER_NAME);
coursefields.add(JsonKey.CREATED_DATE);
Map<String, Object> filter = new HashMap<>();
filter.put("organisations.organisationId", orgId);
try {
Map<String, Object> result =
ElasticSearchUtil.complexSearch(createESRequest(filter, null, coursefields),
ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.user.getTypeName());
if (null != result && !result.isEmpty()) {
List<Map<String, Object>> resultList =
(List<Map<String, Object>>) result.get(JsonKey.CONTENT);
if (null != resultList && !resultList.isEmpty()) {
for (Map<String, Object> dataObject : resultList) {
userResult.add(dataObject);
}
}
}
return userResult;
} catch (Exception e) {
throw new ProjectCommonException(ResponseCode.esError.getErrorCode(),
ResponseCode.esError.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode());
}
}
示例7: getSkill
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
/**
* Method to get the list of skills of the user on basis of UserId ...
* @param actorMessage
*/
private void getSkill(Request actorMessage) {
ProjectLogger.log("SkillmanagementActor-getSkill called");
String endorsedUserId = (String) actorMessage.getRequest().get(JsonKey.ENDORSED_USER_ID);
if(ProjectUtil.isStringNullOREmpty(endorsedUserId)){
throw new ProjectCommonException(ResponseCode.endorsedUserIdRequired.getErrorCode(),
ResponseCode.endorsedUserIdRequired.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
}
Map<String, Object> filter = new HashMap<>();
filter.put(JsonKey.USER_ID, endorsedUserId);
List<String> fields = new ArrayList<>();
fields.add(JsonKey.SKILLS);
Map<String, Object> result = ElasticSearchUtil.complexSearch(createESRequest(filter , null,
fields), ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.user.getTypeName());
if(result.isEmpty() || ((List<Map<String , Object>>)result.get(JsonKey.CONTENT)).isEmpty()){
throw new ProjectCommonException(ResponseCode.invalidUserId.getErrorCode(),
ResponseCode.invalidUserId.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
}
List<Map<String , Object>> skillList = (List<Map<String , Object>>)result.get(JsonKey.CONTENT);
Map<String , Object> skillMap = new HashMap();
if(! skillList.isEmpty()){
skillMap = skillList.get(0);
}
Response response = new Response();
response.getResult().put(JsonKey.SKILLS , skillMap.get(JsonKey.SKILLS));
sender().tell(response , self());
}
示例8: getElasticSearchData
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
/**
* Method to get note data from ElasticSearch
*
* @param searchQueryMap
* @return Map<String, Object> - note data
*/
@SuppressWarnings("unchecked")
private Map<String, Object> getElasticSearchData(Map<String, Object> searchQueryMap) {
Map<String, Object> filters = new HashMap<>();
if (searchQueryMap.containsKey(JsonKey.FILTERS)) {
filters = (Map<String, Object>) searchQueryMap.get(JsonKey.FILTERS);
}
if (null != searchQueryMap.get(JsonKey.REQUESTED_BY)) {
filters.put(JsonKey.USER_ID, searchQueryMap.get(JsonKey.REQUESTED_BY));
}
filters.put(JsonKey.IS_DELETED, false);
searchQueryMap.put(JsonKey.FILTERS, filters);
SearchDTO searchDto = Util.createSearchDto(searchQueryMap);
List<String> excludedFields = new ArrayList<>();
if (null != searchDto.getExcludedFields()) {
excludedFields = searchDto.getExcludedFields();
}
excludedFields.add(JsonKey.IS_DELETED);
searchDto.setExcludedFields(excludedFields);
Map<String, Object> result = ElasticSearchUtil.complexSearch(searchDto,
ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.usernotes.getTypeName());
if (result != null) {
Object count = (Object) result.get(JsonKey.COUNT);
Object note = result.get(JsonKey.CONTENT);
result = new LinkedHashMap<>();
result.put(JsonKey.COUNT, count);
result.put(JsonKey.NOTE, note);
} else {
result = new HashMap<>();
}
return result;
}
示例9: search
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
/**
* This method will allow to search Data from ES.
*
* @return Promise<Result>
*/
@SuppressWarnings("unchecked")
public Promise<Result> search() {
try {
JsonNode requestData = request().body().asJson();
ProjectLogger.log("getting search data request = " + requestData, LoggerEnum.INFO.name());
Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
reqObj.setRequestId(ExecutionContext.getRequestId());
reqObj.setEnv(getEnvironment());
Response response = new Response();
List<String> requiredFields = null;
if (!ProjectUtil.isStringNullOREmpty((String) reqObj.getRequest().get(ENTITY_NAME))) {
String esType = (String) reqObj.getRequest().get(ENTITY_NAME);
if(reqObj.getRequest().containsKey(REQUIRED_FIELDS)) {
requiredFields = (List<String>) reqObj.getRequest().get(REQUIRED_FIELDS);
reqObj.getRequest().remove(REQUIRED_FIELDS);
}
reqObj.getRequest().remove(ENTITY_NAME);
if(null != reqObj.getRequest().get(JsonKey.FILTERS)){
validateRequestData((Map<String, Object>) reqObj.getRequest().get(JsonKey.FILTERS));
}
SearchDTO searchDto = Util.createSearchDto(reqObj.getRequest());
Map<String, Object> result = ElasticSearchUtil.complexSearch(searchDto, ES_INDEX_NAME, esType);
Map<String , Object> finalResult = new HashMap<>();
if (!result.isEmpty()) {
// filter the required fields like content or facet etc...
if(null != requiredFields && !requiredFields.isEmpty()){
for(String attribute : requiredFields){
finalResult.put(attribute , result.get(attribute));
}
result = finalResult;
}
if(result.containsKey(JsonKey.CONTENT)) {
List<Map<String, Object>> mapList =
(List<Map<String, Object>>) result.get(JsonKey.CONTENT);
for (Map<String, Object> map : mapList) {
map.remove(JsonKey.IDENTIFIER);
}
}
response.put(JsonKey.RESPONSE, result);
} else {
response.put(JsonKey.RESPONSE, new HashMap<>());
}
} else {
throw new ProjectCommonException(ResponseCode.tableOrDocNameError.getErrorCode(),
ResponseCode.tableOrDocNameError.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
}
return Promise.<Result>pure(createCommonResponse(response, null, request()));
} catch (Exception e) {
return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
}
}
示例10: getCourseCompletedData
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Map<String, Object> getCourseCompletedData(String periodStr, String courseId, String channel) {
Map<String, Object> dateRange = getStartAndEndDate(periodStr);
Map<String, Object> filter = new HashMap<>();
Map<String, Object> resultMap = new HashMap<>();
filter.put(JsonKey.COURSE_ID, courseId);
Map<String, String> dateRangeFilter = new HashMap<>();
dateRangeFilter.put(GTE, (String) dateRange.get(startDate));
dateRangeFilter.put(LTE, (String) dateRange.get(endDate));
filter.put(JsonKey.DATE_TIME, dateRangeFilter);
filter.put(JsonKey.STATUS, ProjectUtil.ProgressStatus.COMPLETED.getValue());
List<String> coursefields = new ArrayList<>();
coursefields.add(JsonKey.USER_ID);
coursefields.add(JsonKey.PROGRESS);
coursefields.add(JsonKey.STATUS);
Map<String, Object> result =
ElasticSearchUtil.complexSearch(createESRequest(filter, null, coursefields),
ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.usercourses.getTypeName());
if(null==result || result.isEmpty()){
throw new ProjectCommonException(ResponseCode.noDataForConsumption.getErrorCode(),
ResponseCode.noDataForConsumption.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
}
List<Map<String, Object>> esContent = (List<Map<String, Object>>) result.get(JsonKey.CONTENT);
List<String> userIds = new ArrayList<String>();
Double timeConsumed = 0D;
for (Map<String, Object> entry : esContent) {
String userId = (String) entry.get(JsonKey.USER_ID);
timeConsumed = timeConsumed + getMetricsForUser(courseId, userId, periodStr, channel);
userIds.add(userId);
}
Integer users_count = userIds.size();
resultMap.put("user_count", users_count);
if (0 == users_count) {
resultMap.put("avg_time_course_completed", 0);
} else {
resultMap.put("avg_time_course_completed", timeConsumed / users_count);
}
return resultMap;
}
示例11: elasticSearchComplexSearch
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
private Map<String, Object> elasticSearchComplexSearch(Map<String, Object> filters, String index,
String type) {
SearchDTO searchDTO = new SearchDTO();
searchDTO.getAdditionalProperties().put(JsonKey.FILTERS, filters);
return ElasticSearchUtil.complexSearch(searchDTO, index, type);
}
示例12: elasticSearchComplexSearch
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
private Map<String, Object> elasticSearchComplexSearch(Map<String, Object> filters, String index,
String type) {
SearchDTO searchDTO = new SearchDTO();
searchDTO.getAdditionalProperties().put(JsonKey.FILTERS, filters);
return ElasticSearchUtil.complexSearch(searchDTO, index, type);
}
示例13: elasticSearchComplexSearch
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
private static Map<String , Object> elasticSearchComplexSearch(Map<String , Object> filters , String index , String type) {
SearchDTO searchDTO = new SearchDTO();
searchDTO.getAdditionalProperties().put(JsonKey.FILTERS , filters);
return ElasticSearchUtil.complexSearch(searchDTO , index,type);
}