本文整理汇总了Java中org.sunbird.dto.SearchDTO类的典型用法代码示例。如果您正苦于以下问题:Java SearchDTO类的具体用法?Java SearchDTO怎么用?Java SearchDTO使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SearchDTO类属于org.sunbird.dto包,在下文中一共展示了SearchDTO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateHashTagId
import org.sunbird.dto.SearchDTO; //导入依赖的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.dto.SearchDTO; //导入依赖的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.dto.SearchDTO; //导入依赖的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.dto.SearchDTO; //导入依赖的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: getConstraints
import org.sunbird.dto.SearchDTO; //导入依赖的package包/类
private static Map<String, Float> getConstraints(SearchDTO searchDTO) {
if (!(searchDTO.getMode().isEmpty())) {
if (searchDTO.getMode().contains(SOFT_MODE)) {
return searchDTO.getSoftConstraints().entrySet().stream()
.collect(Collectors.toMap(
e -> e.getKey(),
e -> e.getValue().floatValue()
));
}
}
return new HashMap<String, Float>();
}
示例6: testComplexSearchWithRangeGreater
import org.sunbird.dto.SearchDTO; //导入依赖的package包/类
@Test
public void testComplexSearchWithRangeGreater(){
SearchDTO searchDTO = new SearchDTO();
Map<String , Object> additionalProperties = new HashMap<String , Object>();
List<Integer> sizes = new ArrayList<Integer>();
sizes.add(10);
sizes.add(20);
Map<String , Object> filterMap = new HashMap<String , Object>();
filterMap.put("size" , sizes);
Map<String, String> innerMap = new HashMap<>();
innerMap.put("createdOn", "2017-11-06");
filterMap.put(">=", innerMap);
additionalProperties.put(JsonKey.FILTERS,filterMap);
Map<String, Object> rangeMap = new HashMap<String , Object>();
rangeMap.put(">",0);
filterMap.put("pkgVersion" , rangeMap);
Map<String , Object> lexicalMap = new HashMap<>();
lexicalMap.put(STARTS_WITH , "type");
filterMap.put("courseType" , lexicalMap);
Map<String , Object> lexicalMap1 = new HashMap<>();
lexicalMap1.put(ENDS_WITH , "sunbird");
filterMap.put("courseAddedByName" , lexicalMap1);
//for exact math key value pair
filterMap.put("orgName" , "Name of the organisation");
searchDTO.setAdditionalProperties(additionalProperties);
searchDTO.setQuery("organisation");
Map map = ElasticSearchUtil.complexSearch(searchDTO,indexName , typeName);
List response = (List) map.get(JsonKey.RESPONSE);
assertEquals(2 , map.size());
}
示例7: testComplexSearchWithRangeLessThan
import org.sunbird.dto.SearchDTO; //导入依赖的package包/类
@Test
public void testComplexSearchWithRangeLessThan(){
SearchDTO searchDTO = new SearchDTO();
Map<String , Object> additionalProperties = new HashMap<String , Object>();
List<Integer> sizes = new ArrayList<Integer>();
sizes.add(10);
sizes.add(20);
Map<String , Object> filterMap = new HashMap<String , Object>();
filterMap.put("size" , sizes);
Map<String, String> innerMap = new HashMap<>();
innerMap.put("createdOn", "2017-11-06");
filterMap.put("<=", innerMap);
additionalProperties.put(JsonKey.FILTERS,filterMap);
Map<String, Object> rangeMap = new HashMap<String , Object>();
rangeMap.put(">",0);
filterMap.put("pkgVersion" , rangeMap);
Map<String , Object> lexicalMap = new HashMap<>();
lexicalMap.put(STARTS_WITH , "type");
filterMap.put("courseType" , lexicalMap);
Map<String , Object> lexicalMap1 = new HashMap<>();
lexicalMap1.put(ENDS_WITH , "sunbird");
filterMap.put("courseAddedByName" , lexicalMap1);
//for exact math key value pair
filterMap.put("orgName" , "Name of the organisation");
searchDTO.setAdditionalProperties(additionalProperties);
searchDTO.setQuery("organisation");
Map map = ElasticSearchUtil.complexSearch(searchDTO,indexName , typeName);
List response = (List) map.get(JsonKey.RESPONSE);
assertEquals(2 , map.size());
}
示例8: searchDtoGetQueryTest
import org.sunbird.dto.SearchDTO; //导入依赖的package包/类
@Test
public void searchDtoGetQueryTest() {
SearchDTO dto = new SearchDTO();
List<Map<String,Object>> list = new ArrayList<>();
Map<String,Object> map = new HashMap<>();
map.put("name", "test1");
list.add(map);
dto.setGroupQuery(list);
list = dto.getGroupQuery();
assertEquals(1, list.size());
dto.setOperation("add");
assertEquals("add", dto.getOperation());
dto.setFuzzySearch(true);
assertTrue(dto.isFuzzySearch());
}
示例9: searchDtoArgumentedConst
import org.sunbird.dto.SearchDTO; //导入依赖的package包/类
@Test
public void searchDtoArgumentedConst() {
List<Map> list = new ArrayList<>();
Map map = new HashMap();
map.put("name", "test1");
list.add(map);
SearchDTO dto = new SearchDTO(list,"add",5);
assertEquals(1, dto.getProperties().size());
map.put("city", "mycity");
list.add(map);
dto.setProperties(list);
assertEquals(2, dto.getProperties().get(0).size());
}
示例10: createESRequest
import org.sunbird.dto.SearchDTO; //导入依赖的package包/类
protected SearchDTO createESRequest(Map<String, Object> filters, Map<String, String> aggs,
List<String> fields) {
SearchDTO searchDTO = new SearchDTO();
searchDTO.getAdditionalProperties().put(JsonKey.FILTERS, filters);
if (isNotNull(aggs)) {
searchDTO.getFacets().add(aggs);
}
if (isNotNull(fields)) {
searchDTO.setFields(fields);
}
return searchDTO;
}
示例11: createESRequest
import org.sunbird.dto.SearchDTO; //导入依赖的package包/类
protected SearchDTO createESRequest(Map<String, Object> filters, Map<String, String> aggs,
List<String> fields) {
SearchDTO searchDTO = new SearchDTO();
searchDTO.getAdditionalProperties().put(JsonKey.FILTERS, filters);
if (ProjectUtil.isNotNull(aggs)) {
searchDTO.getFacets().add(aggs);
}
if (ProjectUtil.isNotNull(fields)) {
searchDTO.setFields(fields);
}
return searchDTO;
}
示例12: getElasticSearchData
import org.sunbird.dto.SearchDTO; //导入依赖的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;
}
示例13: testComplexSearch
import org.sunbird.dto.SearchDTO; //导入依赖的package包/类
@Test
public void testComplexSearch(){
SearchDTO searchDTO = new SearchDTO();
List<String> fields = new ArrayList<String>();
fields.add("courseId");
fields.add("courseType");
fields.add("createdOn");
fields.add("description");
List<String> excludefields = new ArrayList<String>();
excludefields.add("createdOn");
Map<String , String> sortMap = new HashMap<>();
sortMap.put("courseType" , "ASC");
searchDTO.setSortBy(sortMap);
searchDTO.setExcludedFields(excludefields);
searchDTO.setLimit(20);
searchDTO.setOffset(0);
Map<String,Object> additionalPro = new HashMap<String, Object>();
searchDTO.addAdditionalProperty("test", additionalPro);
Map<String , Object> additionalProperties = new HashMap<String , Object>();
List<String> existsList = new ArrayList<String>();
existsList.add("pkgVersion");
existsList.add("size");
additionalProperties.put(JsonKey.EXISTS , existsList);
List<String> description = new ArrayList<String>();
description.add("This is for chemistry");
description.add("Hindi Jii");
List<Integer> sizes = new ArrayList<Integer>();
sizes.add(10);
sizes.add(20);
Map<String , Object> filterMap = new HashMap<String , Object>();
filterMap.put("description" , description);
filterMap.put("size" , sizes);
additionalProperties.put(JsonKey.FILTERS,filterMap);
Map<String, Object> rangeMap = new HashMap<String , Object>();
rangeMap.put(">",0);
filterMap.put("pkgVersion" , rangeMap);
Map<String , Object> lexicalMap = new HashMap<>();
lexicalMap.put(STARTS_WITH , "type");
filterMap.put("courseType" , lexicalMap);
Map<String , Object> lexicalMap1 = new HashMap<>();
lexicalMap1.put(ENDS_WITH , "sunbird");
filterMap.put("courseAddedByName" , lexicalMap1);
//for exact math key value pair
filterMap.put("orgName" , "Name of the organisation");
searchDTO.setAdditionalProperties(additionalProperties);
searchDTO.setFields(fields);
searchDTO.setQuery("organisation");
//facets
List<Map<String,String>> facets = new ArrayList<>();
Map<String , String> m1 = new HashMap<>();
m1.put("description" , null);
m1.put("createdOn", JsonKey.DATE_HISTOGRAM);
facets.add(m1);
searchDTO.setFacets(facets);
//soft constraints
List<String> mode = Arrays.asList("soft");
searchDTO.setMode(mode);
Map<String , Integer> constraintMap = new HashMap<String , Integer>();
constraintMap.put("grades" , 10);
constraintMap.put("pkgVersion" , 5);
searchDTO.setSoftConstraints(constraintMap);
searchDTO.setQuery("organisation Name published");
Map map = ElasticSearchUtil.complexSearch(searchDTO,indexName , typeName);
List response = (List) map.get(JsonKey.RESPONSE);
assertEquals(3 , map.size());
//assertNotNull(map);
}
示例14: search
import org.sunbird.dto.SearchDTO; //导入依赖的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()));
}
}
示例15: elasticSearchComplexSearch
import org.sunbird.dto.SearchDTO; //导入依赖的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);
}