本文整理汇总了Java中org.jai.search.model.SearchCriteria.indices方法的典型用法代码示例。如果您正苦于以下问题:Java SearchCriteria.indices方法的具体用法?Java SearchCriteria.indices怎么用?Java SearchCriteria.indices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jai.search.model.SearchCriteria
的用法示例。
在下文中一共展示了SearchCriteria.indices方法的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: 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);
}
}
示例3: 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());
}
示例4: 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());
}
示例5: 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());
}
示例6: 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());
}
示例7: 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());
}
示例8: 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());
}
}
}
示例9: 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());
}
示例10: configureDataForAvoidingQueryOnHTMLTags
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void configureDataForAvoidingQueryOnHTMLTags()
{
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
String htmlTag = "br";
searchCriteria.query(htmlTag);
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 html content
description = description + " " + "<div><p>This contains html content</p><div><br/>";
product.setDescription(description);
indexProductData.indexProduct(config, product);
refreshSearchServer();
//Expected to find with "br" search but is not allowed in indexing
searchCriteria.query(htmlTag);
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(0, searchProducts.getTotalCount());
assertEquals(0, searchProducts.getProducts().size());
}
示例11: 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());
}
示例12: findSimilarProducts
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void findSimilarProducts()
{
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
//0-4 products with color red
Long productId = 0l;
String[] fields = new String[]{SearchFacetName.CATEGORIES_FIELD_PREFIX + SearchFacetName.SEARCH_FACET_TYPE_COLOR.getFacetFieldNameAtLevel(2) + ".facet"};
List<Product> similarProducts = productQueryService.findSimilarProducts(config, fields, productId);
assertEquals(4, similarProducts.size());
assertTrue(similarProducts.get(0).getId() < 5);
//only Macbook products, 9 excluding current one
fields = new String[]{SearchFacetName.CATEGORIES_FIELD_PREFIX + SearchFacetName.SEARCH_FACET_TYPE_PRODUCT_TYPE.getFacetFieldNameAtLevel(3) + ".facet"};
similarProducts = productQueryService.findSimilarProducts(config, fields, productId);
assertEquals(9, similarProducts.size());
fields = new String[]{SearchFacetName.CATEGORIES_FIELD_PREFIX + SearchFacetName.SEARCH_FACET_TYPE_PRODUCT_TYPE.getFacetFieldNameAtLevel(3) + ".facet",
SearchFacetName.CATEGORIES_FIELD_PREFIX + SearchFacetName.SEARCH_FACET_TYPE_PRODUCT_TYPE.getFacetFieldNameAtLevel(4) + ".facet"};
similarProducts = productQueryService.findSimilarProducts(config, fields, productId);
assertEquals(9, similarProducts.size());
Product product = productQueryService.getProduct(config, productId);
//the first 4 products on matching two fields, macbook air
//rest 5 products on matching only one field, macbook
assertTrue(product.categoryNameExists(SampleDataGenerator.MACBOOK_AIR));
for (int i = 0; i < 9; i++)
{
product = productQueryService.getProduct(config, similarProducts.get(i).getId());
System.out.println(product);
if(i < 4)
{
assertTrue(product.categoryNameExists(SampleDataGenerator.MACBOOK_AIR));
}
else
{
assertTrue(product.categoryNameExists(SampleDataGenerator.MACBOOK_PRO));
}
}
}
示例13: 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());
}
示例14: facetingOnNestedObjectsOnProductSpecificationsResolutionAndMemory
import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Test
public void facetingOnNestedObjectsOnProductSpecificationsResolutionAndMemory()
{
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
searchCriteria.facets(SearchFacetName.SPECIFICATION_RESOLUTION.getCode());
searchCriteria.facets(SearchFacetName.SPECIFICATION_MEMORY.getCode());
ProductSearchResult searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(50, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
assertEquals(2, searchProducts.getFacets().size());
//Only 5 docs with 3200 x 1800
searchCriteria.addMultiSelectFilter(SearchFacetName.SPECIFICATION_RESOLUTION.getCode(), SampleDataGenerator.RESOLUTON_3200_1800);
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(5, searchProducts.getTotalCount());
assertEquals(5, searchProducts.getProducts().size());
assertEquals(2, searchProducts.getFacets().size());
//Only 5 docs with and 8 GB
searchCriteria.getMultiSelectFilters().clear();
searchCriteria.addMultiSelectFilter(SearchFacetName.SPECIFICATION_MEMORY.getCode(), SampleDataGenerator.MEMORY_8_GB);
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(5, searchProducts.getTotalCount());
assertEquals(5, searchProducts.getProducts().size());
assertEquals(2, searchProducts.getFacets().size());
//Only 5 docs with both
searchCriteria.getMultiSelectFilters().clear();
searchCriteria.addMultiSelectFilter(SearchFacetName.SPECIFICATION_RESOLUTION.getCode(), SampleDataGenerator.RESOLUTON_3200_1800);
searchCriteria.addMultiSelectFilter(SearchFacetName.SPECIFICATION_MEMORY.getCode(), SampleDataGenerator.MEMORY_8_GB);
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(5, searchProducts.getTotalCount());
assertEquals(5, searchProducts.getProducts().size());
assertEquals(2, searchProducts.getFacets().size());
//no docs for below combination
searchCriteria.getMultiSelectFilters().clear();
searchCriteria.addMultiSelectFilter(SearchFacetName.SPECIFICATION_RESOLUTION.getCode(), SampleDataGenerator.RESOLUTON_3200_1800);
searchCriteria.addMultiSelectFilter(SearchFacetName.SPECIFICATION_MEMORY.getCode(), SampleDataGenerator.MEMORY_6_GB);
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(0, searchProducts.getTotalCount());
assertEquals(0, searchProducts.getProducts().size());
assertEquals(0, searchProducts.getFacets().size());
//10 docs for 6 gb and 8 gb
searchCriteria.getMultiSelectFilters().clear();
searchCriteria.addMultiSelectFilter(SearchFacetName.SPECIFICATION_MEMORY.getCode(), SampleDataGenerator.MEMORY_8_GB);
searchCriteria.addMultiSelectFilter(SearchFacetName.SPECIFICATION_MEMORY.getCode(), SampleDataGenerator.MEMORY_6_GB);
searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(10, searchProducts.getTotalCount());
assertEquals(10, searchProducts.getProducts().size());
assertEquals(2, searchProducts.getFacets().size());
}
示例15: 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());
}