本文整理汇总了Java中org.jai.search.model.SearchCriteria.size方法的典型用法代码示例。如果您正苦于以下问题:Java SearchCriteria.size方法的具体用法?Java SearchCriteria.size怎么用?Java SearchCriteria.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jai.search.model.SearchCriteria
的用法示例。
在下文中一共展示了SearchCriteria.size方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSearchCriteria
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
private SearchCriteria getSearchCriteria() {
final ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
final SearchCriteria searchCriteria = new SearchCriteria()
.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
searchCriteria.size(50);
for (final SearchFacetName facet : SearchFacetName.categoryFacets) {
searchCriteria.facets(facet.getFacetFieldNameAtLevel(2));
}
searchCriteria.facets(SearchFacetName.PRODUCT_PRICE_RANGE.getCode());
searchCriteria.facets(SearchFacetName.PRODUCT_PROPERTY_SIZE.getCode());
searchCriteria.facets(SearchFacetName.PRODUCT_PROPERTY_COLOR.getCode());
searchCriteria.facets(SearchFacetName.SPECIFICATION_RESOLUTION
.getCode());
searchCriteria.facets(SearchFacetName.SPECIFICATION_MEMORY.getCode());
return searchCriteria;
}
示例2: paginatedDocumentResults
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void paginatedDocumentResults()
{
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
searchCriteria.size(0);
ProductSearchResult searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(50, searchProducts.getTotalCount());
assertEquals(0, searchProducts.getProducts().size());
}
示例3: searchInMultipleIndexes
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void searchInMultipleIndexes()
{
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName(), ElasticSearchIndexConfig.NL_WEBSITE.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
searchCriteria.size(0);
ProductSearchResult searchProducts = productQueryService.searchProducts(searchCriteria);
//50 + 50 docs from both indices
assertEquals(100, searchProducts.getTotalCount());
assertEquals(0, searchProducts.getProducts().size());
}
示例4: boostingDocumentsUsingRescoreOnSoldOut
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void boostingDocumentsUsingRescoreOnSoldOut()
{
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
searchCriteria.size(50);
ProductSearchResult searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(50, searchProducts.getTotalCount());
assertEquals(50, searchProducts.getProducts().size());
//By default, even ids are sold out and odd are soldout=false
searchCriteria.rescoreOnSoldOut(true);
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(50, searchProducts.getTotalCount());
assertEquals(50, searchProducts.getProducts().size());
for (int i = 0; i < 50; i++)
{
if (i < 25)
{
//not sold out, still available
assertFalse(searchProducts.getProducts().get(i).isSoldOut());
}
else
{
//product sold out
assertTrue(searchProducts.getProducts().get(i).isSoldOut());
}
}
}
示例5: paginatedDocumentResults
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void paginatedDocumentResults() {
final ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
final SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
searchCriteria.size(0);
final ProductSearchResult searchProducts = productQueryService
.searchProducts(searchCriteria);
assertEquals(50, searchProducts.getTotalCount());
assertEquals(0, searchProducts.getProducts().size());
}
示例6: searchInMultipleIndexes
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void searchInMultipleIndexes() {
final ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
final SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName(),
ElasticSearchIndexConfig.NL_WEBSITE.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
searchCriteria.size(0);
final ProductSearchResult searchProducts = productQueryService
.searchProducts(searchCriteria);
// 50 + 50 docs from both indices
assertEquals(100, searchProducts.getTotalCount());
assertEquals(0, searchProducts.getProducts().size());
}
示例7: facetingOnHierarchicalDataOnProductCategories
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void facetingOnHierarchicalDataOnProductCategories()
{
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
for (SearchFacetName facet : SearchFacetName.categoryFacets)
{
searchCriteria.facets(facet.getFacetFieldNameAtLevel(2));
}
searchCriteria.facets(SearchFacetName.PRODUCT_PRICE_RANGE.getCode());
ProductSearchResult searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(50, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
assertEquals(5, searchProducts.getFacets().size());
searchCriteria.addSingleSelectFilter(SearchFacetName.SEARCH_FACET_TYPE_PRODUCT_TYPE.getFacetFieldNameAtLevel(3), SampleDataGenerator.MACBOOK);
searchCriteria.size(50);
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(10, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
assertEquals(5, searchProducts.getFacets().size());
searchCriteria.getSingleSelectFilters().clear();
searchCriteria.addMultiSelectFilter(SearchFacetName.SEARCH_FACET_TYPE_COLOR.getFacetFieldNameAtLevel(2), SampleDataGenerator.RED);
searchCriteria.addMultiSelectFilter(SearchFacetName.SEARCH_FACET_TYPE_COLOR.getFacetFieldNameAtLevel(2), SampleDataGenerator.BLUE);
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(10, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
assertEquals(5, searchProducts.getFacets().size());
searchCriteria.getMultiSelectFilters().clear();
searchCriteria.addSingleSelectFilter(SearchFacetName.PRODUCT_PRICE_RANGE.getCode(), "0 - 10");
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(10, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
assertEquals(5, searchProducts.getFacets().size());
searchCriteria.getSingleSelectFilters().clear();
searchCriteria.addFiledValueFilter(SearchDocumentFieldName.SOLD_OUT.getFieldName(), true);
searchCriteria.size(10);
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(25, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
assertEquals(5, searchProducts.getFacets().size());
searchCriteria.getFieldValueFilters().clear();
searchCriteria.query("title");
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(50, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
assertEquals(5, searchProducts.getFacets().size());
}
示例8: influencingScoreForDocumentsUsingFieldsWeight
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void influencingScoreForDocumentsUsingFieldsWeight()
{
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
searchCriteria.useBoostingFactor(true);
searchCriteria.size(50);
ProductSearchResult searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(50, searchProducts.getTotalCount());
assertEquals(50, searchProducts.getProducts().size());
assertEquals(49, searchProducts.getProducts().get(0).getId().intValue());
assertEquals(0, searchProducts.getProducts().get(49).getId().intValue());
int j=0;
for (Product product : searchProducts.getProducts())
{
Product productDoc = productQueryService.getProduct(config, product.getId());
//Clear out categories, as parent was not set properly..will cause issues in reindexing...ignoring as temp data.
productDoc.getCategories().clear();
//set description in reverse order.
productDoc.setDescription("Description " + j);
indexProductData.indexProduct(config, productDoc);
j++;
}
refreshSearchServer();
//query for string 10.
//title field weight TITLE: (float) 0.5) DESCRIPTION : (float) 0.15)
searchCriteria.query("10");
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(2, searchProducts.getTotalCount());
assertEquals(2, searchProducts.getProducts().size());
assertEquals(10, searchProducts.getProducts().get(0).getId().intValue());
assertEquals("Title 10", searchProducts.getProducts().get(0).getTitle());
assertEquals("Description 10", productQueryService.getProduct(config, searchProducts.getProducts().get(1).getId()).getDescription());
}