當前位置: 首頁>>代碼示例>>Java>>正文


Java SortField.DOUBLE屬性代碼示例

本文整理匯總了Java中org.apache.lucene.search.SortField.DOUBLE屬性的典型用法代碼示例。如果您正苦於以下問題:Java SortField.DOUBLE屬性的具體用法?Java SortField.DOUBLE怎麽用?Java SortField.DOUBLE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.lucene.search.SortField的用法示例。


在下文中一共展示了SortField.DOUBLE屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: extractProducts

public Map<Integer , List<Products>> extractProducts( String id , int page ) {

        FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(
                em );

        QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(
                Products.class ).get();
        org.apache.lucene.search.Query query = queryBuilder.keyword().onField( "category.id" ).matching(
                id ).createQuery();

        FullTextQuery fullTextQuery = fullTextEntityManager.createFullTextQuery( query ,
                                                                                 Products.class );
        Sort sort = new Sort( new SortField( "price" , SortField.DOUBLE ) );
        fullTextQuery.setSort( sort );

        //fullTextQuery.initializeObjectsWith(ObjectLookupMethod.SKIP, DatabaseRetrievalMethod.FIND_BY_ID);
        fullTextQuery.setFirstResult( page * 3 );
        fullTextQuery.setMaxResults( 3 );
        List<Products> results = fullTextQuery.getResultList();

        Map<Integer , List<Products>> results_and_total = new HashMap<Integer , List<Products>>();
        results_and_total.put( fullTextQuery.getResultSize() , results );

        return results_and_total;
    }
 
開發者ID:juliocnsouzadev,項目名稱:omg_mongodb,代碼行數:25,代碼來源:EShopBean.java

示例2: extractPromotionalProducts

public List<Products> extractPromotionalProducts() {

        FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(
                em );

        org.apache.lucene.search.Query query = NumericRangeQuery.newDoubleRange( "old_price" , 0.0d ,
                                                                                 1000d , false ,
                                                                                 true );
        FullTextQuery fullTextQuery = fullTextEntityManager.createFullTextQuery( query ,
                                                                                 Products.class );
        Sort sort = new Sort( new SortField( "price" , SortField.DOUBLE ) );
        fullTextQuery.setSort( sort );

        //fullTextQuery.initializeObjectsWith(ObjectLookupMethod.SKIP, DatabaseRetrievalMethod.FIND_BY_ID);
        List results = fullTextQuery.getResultList();

        return results;
    }
 
開發者ID:juliocnsouzadev,項目名稱:omg_mongodb,代碼行數:18,代碼來源:EShopBean.java


注:本文中的org.apache.lucene.search.SortField.DOUBLE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。