当前位置: 首页>>代码示例>>Java>>正文


Java SearchDTO.setLimit方法代码示例

本文整理汇总了Java中org.sunbird.dto.SearchDTO.setLimit方法的典型用法代码示例。如果您正苦于以下问题:Java SearchDTO.setLimit方法的具体用法?Java SearchDTO.setLimit怎么用?Java SearchDTO.setLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sunbird.dto.SearchDTO的用法示例。


在下文中一共展示了SearchDTO.setLimit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
}
 
开发者ID:project-sunbird,项目名称:sunbird-utils,代码行数:75,代码来源:ElasticSearchUtilTest.java

示例2: createSearchDto

import org.sunbird.dto.SearchDTO; //导入方法依赖的package包/类
/**
 * This method will take searchQuery map and internally it will convert map to
 * SearchDto object.
 * @param searchQueryMap Map<String , Object>
 * @return SearchDTO
 */
@SuppressWarnings("unchecked")
public static SearchDTO createSearchDto(Map<String , Object> searchQueryMap){
    SearchDTO search = new SearchDTO();
    if(searchQueryMap.containsKey(JsonKey.QUERY)){
     search.setQuery((String) searchQueryMap.get(JsonKey.QUERY));
    }
    if(searchQueryMap.containsKey(JsonKey.FACETS)){
        search.setFacets((List<Map<String , String>>) searchQueryMap.get(JsonKey.FACETS));
    }
    if(searchQueryMap.containsKey(JsonKey.FIELDS)){
        search.setFields((List<String>) searchQueryMap.get(JsonKey.FIELDS));
    }
    if(searchQueryMap.containsKey(JsonKey.FILTERS)){
        search.getAdditionalProperties().put(JsonKey.FILTERS,searchQueryMap.get(JsonKey.FILTERS));
    }
    if(searchQueryMap.containsKey(JsonKey.EXISTS)){
        search.getAdditionalProperties().put(JsonKey.EXISTS, searchQueryMap.get(JsonKey.EXISTS));
    }
    if(searchQueryMap.containsKey(JsonKey.NOT_EXISTS)){
        search.getAdditionalProperties().put(JsonKey.NOT_EXISTS, searchQueryMap.get(JsonKey.NOT_EXISTS));
    }
    if(searchQueryMap.containsKey(JsonKey.SORT_BY)){
        search.getSortBy().putAll((Map<? extends String, ? extends String>) searchQueryMap.get(JsonKey.SORT_BY));
    }
    if(searchQueryMap.containsKey(JsonKey.OFFSET)){
        if((searchQueryMap.get(JsonKey.OFFSET)) instanceof Integer ){
            search.setOffset((int)searchQueryMap.get(JsonKey.OFFSET));
        }else{
            search.setOffset(((BigInteger) searchQueryMap.get(JsonKey.OFFSET)).intValue());
        }
    }
    if(searchQueryMap.containsKey(JsonKey.LIMIT)){
        if((searchQueryMap.get(JsonKey.LIMIT)) instanceof Integer ){
            search.setLimit((int)searchQueryMap.get(JsonKey.LIMIT));
        }else{
            search.setLimit(((BigInteger) searchQueryMap.get(JsonKey.LIMIT)).intValue());
        }
    }
    if(searchQueryMap.containsKey(JsonKey.GROUP_QUERY)){
        search.getGroupQuery().addAll((Collection<? extends Map<String, Object>>) searchQueryMap.get(JsonKey.GROUP_QUERY));
    }
    return search;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:50,代码来源:Util.java


注:本文中的org.sunbird.dto.SearchDTO.setLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。