本文整理汇总了Java中org.sunbird.dto.SearchDTO.setExcludedFields方法的典型用法代码示例。如果您正苦于以下问题:Java SearchDTO.setExcludedFields方法的具体用法?Java SearchDTO.setExcludedFields怎么用?Java SearchDTO.setExcludedFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sunbird.dto.SearchDTO
的用法示例。
在下文中一共展示了SearchDTO.setExcludedFields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}