本文整理汇总了Java中org.jai.search.model.SearchCriteria.documentTypes方法的典型用法代码示例。如果您正苦于以下问题:Java SearchCriteria.documentTypes方法的具体用法?Java SearchCriteria.documentTypes怎么用?Java SearchCriteria.documentTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jai.search.model.SearchCriteria
的用法示例。
在下文中一共展示了SearchCriteria.documentTypes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SearchDocumentReturnedFileds
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void SearchDocumentReturnedFileds()
{
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
ProductSearchResult searchProducts = productQueryService.searchProducts(searchCriteria);
//50, returned based on boosting.
assertEquals(50, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
for (Product product : searchProducts.getProducts())
{
assertEquals("Title "+product.getId(), product.getTitle());
assertEquals(product.getId().floatValue(), product.getPrice().floatValue(), 0);
}
}
示例2: 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;
}
示例3: queryText
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void queryText() {
final ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
final SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
searchCriteria.query("query");
ProductSearchResult searchProducts = productQueryService
.searchProducts(searchCriteria);
// 50 + 50 docs from both indices
assertEquals(0, searchProducts.getTotalCount());
assertEquals(0, searchProducts.getProducts().size());
searchCriteria.query("Title");
searchProducts = productQueryService.searchProducts(searchCriteria);
// 50 + 50 docs from both indices
assertEquals(50, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
searchCriteria.query("tile*");
searchProducts = productQueryService.searchProducts(searchCriteria);
// 0, special characters are escaped out
assertEquals(0, searchProducts.getTotalCount());
assertEquals(0, searchProducts.getProducts().size());
}
示例4: filteringOnChildDocumentsOnProductProperties
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void filteringOnChildDocumentsOnProductProperties()
{
//set up parent child relationship docs
setupIndexService.setupAllIndices(true);
refreshSearchServer();
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
//search for the products for productproperties
ProductProperty findProductProperty = sampleDataGenerator.findProductProperty(SampleDataGenerator.PRODUCTPROPERTY_SIZE_21_INCH, SampleDataGenerator.PRODUCTPROPERTY_COLOR_BROWN);
assertNotNull(findProductProperty);
searchCriteria.addProductProperty(findProductProperty);
ProductSearchResult searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(1, searchProducts.getTotalCount());
assertEquals(1, searchProducts.getProducts().size());
}
示例5: SearchDocumentReturnedFileds
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void SearchDocumentReturnedFileds() {
final ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
final SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
final ProductSearchResult searchProducts = productQueryService
.searchProducts(searchCriteria);
// 50, returned based on boosting.
assertEquals(50, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
for (final Product product : searchProducts.getProducts()) {
assertEquals("Title " + product.getId(), product.getTitle());
assertEquals(product.getId().floatValue(), product.getPrice()
.floatValue(), 0);
}
}
示例6: 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());
}
示例7: 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());
}
示例8: queryText
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void queryText()
{
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
searchCriteria.query("query");
ProductSearchResult searchProducts = productQueryService.searchProducts(searchCriteria);
//50 + 50 docs from both indices
assertEquals(0, searchProducts.getTotalCount());
assertEquals(0, searchProducts.getProducts().size());
searchCriteria.query("Title");
searchProducts = productQueryService.searchProducts(searchCriteria);
//50 + 50 docs from both indices
assertEquals(50, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
searchCriteria.query("tile*");
searchProducts = productQueryService.searchProducts(searchCriteria);
//0, special characters are escaped out
assertEquals(0, searchProducts.getTotalCount());
assertEquals(0, searchProducts.getProducts().size());
}
示例9: boostingDocumentsUsingFunctionScoreAndScriptScore
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void boostingDocumentsUsingFunctionScoreAndScriptScore()
{
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
searchCriteria.useBoostingFactor(true);
ProductSearchResult searchProducts = productQueryService.searchProducts(searchCriteria);
Long currentTopProductId = searchProducts.getProducts().get(0).getId();
assertEquals(50, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
assertEquals(49, currentTopProductId.intValue());
assertEquals(currentTopProductId/10000f, productQueryService.getProduct(config, currentTopProductId).getBoostFactor(), 0);
//Change boosting factor of one product and see it is at top
long newTopProductId = 23l;
Product product = productQueryService.getProduct(config, newTopProductId);
product.getCategories().clear();
assertEquals(newTopProductId/10000f, product.getBoostFactor(), 0);
product.setBoostFactor(60f);
indexProductData.indexProduct(config, product);
refreshSearchServer();
searchProducts = productQueryService.searchProducts(searchCriteria);
currentTopProductId = searchProducts.getProducts().get(0).getId();
assertEquals(50, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
assertEquals(newTopProductId, currentTopProductId.intValue());
assertEquals(60f, productQueryService.getProduct(config, currentTopProductId).getBoostFactor(), 0);
}
示例10: 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());
}
}
}
示例11: configureDataForStopwords
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void configureDataForStopwords()
{
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
String stopword = "however";
searchCriteria.query(stopword);
Product product = productQueryService.getProduct(config, 1l);
product.getCategories().clear();
ProductSearchResult searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(0, searchProducts.getTotalCount());
assertEquals(0, searchProducts.getProducts().size());
String description = product.getDescription();
assertEquals("Description"+ product.getId(), description);
//Update stop_en_EN however
description = description + " " + stopword;
product.setDescription(description);
indexProductData.indexProduct(config, product);
refreshSearchServer();
//Expected to find but is not allowed in search
searchCriteria.query(stopword);
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(0, searchProducts.getTotalCount());
assertEquals(0, searchProducts.getProducts().size());
}
示例12: 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());
}
示例13: filteringOnNestedDocumentsOnProductsSpecifications
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void filteringOnNestedDocumentsOnProductsSpecifications()
{
//set up parent child relationship docs
setupIndexService.setupAllIndices(false);
refreshSearchServer();
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
//search for the products for productproperties
//5 MACBOOK_AIR
searchCriteria.addSpecifications(new Specification(SampleDataGenerator.RESOLUTON_3200_1800, SampleDataGenerator.MEMORY_8_GB));
ProductSearchResult searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(5, searchProducts.getTotalCount());
assertEquals(5, searchProducts.getProducts().size());
//5 MACBOOK_PRO
searchCriteria.addSpecifications(new Specification(SampleDataGenerator.RESOLUTON_1920_1200, SampleDataGenerator.MEMORY_6_GB));
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(10, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
searchCriteria.getSpecifications().clear();
//None for cross combination
searchCriteria.addSpecifications(new Specification(SampleDataGenerator.RESOLUTON_1920_1200, SampleDataGenerator.MEMORY_8_GB));
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(0, searchProducts.getTotalCount());
assertEquals(0, searchProducts.getProducts().size());
}
示例14: 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());
}
示例15: 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());
}