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


Java SearchCriteria类代码示例

本文整理汇总了Java中org.jai.search.model.SearchCriteria的典型用法代码示例。如果您正苦于以下问题:Java SearchCriteria类的具体用法?Java SearchCriteria怎么用?Java SearchCriteria使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SearchCriteria类属于org.jai.search.model包,在下文中一共展示了SearchCriteria类的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);
    }
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:21,代码来源:ElasticSearchTutPart2Test.java

示例2: 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());
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:24,代码来源:ElasticSearchTutPart5Test.java

示例3: getSearchEvents

import org.jai.search.model.SearchCriteria; //导入依赖的package包/类
@Override
public List<Event> getSearchEvents(int numberOfEvents) {
	try {
		List<Event> events = new ArrayList<>();
		final SearchCriteria searchCriteria = getSearchCriteria();
		final ProductSearchResult searchProducts = productQueryService
				.searchProducts(searchCriteria);

		for (int i = 1; i <= numberOfEvents; i++) {
			final SearchQueryInstruction searchQueryInstruction = getRandomSearchQueryInstruction(
					i, searchProducts);
			final Event event = getJsonEvent(searchQueryInstruction);
			events.add(event);
		}
		return events;
	} catch (UnknownHostException | JsonProcessingException ex) {
		throw new RuntimeException(
				"Error occured while generating search events!", ex);
	}
}
 
开发者ID:jaibeermalik,项目名称:searchanalytics-bigdata,代码行数:21,代码来源:GenerateSearchAnalyticsDataImpl.java

示例4: 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;
}
 
开发者ID:jaibeermalik,项目名称:searchanalytics-bigdata,代码行数:18,代码来源:GenerateSearchAnalyticsDataImpl.java

示例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);
	}
}
 
开发者ID:jaibeermalik,项目名称:searchanalytics-bigdata,代码行数:18,代码来源:ElasticSearchTest.java

示例6: 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());
}
 
开发者ID:jaibeermalik,项目名称:searchanalytics-bigdata,代码行数:24,代码来源:ElasticSearchTest.java

示例7: getQueryBuilder

import org.jai.search.model.SearchCriteria; //导入依赖的package包/类
protected QueryBuilder getQueryBuilder(SearchCriteria searchCriteria)
{
    QueryBuilder matchQueryBuilder = null;
    
    String queryString = searchCriteria.getQuery();
    
    if (StringUtils.isBlank(queryString))
    {
        matchQueryBuilder = QueryBuilders.matchAllQuery();
    } 
    else
    {
        final String filterSpecialCharsQueryString = escapeQueryChars(queryString);
        final QueryStringQueryBuilder queryStringQueryBuilder = QueryBuilders.queryString(filterSpecialCharsQueryString);

        // Add fields
        queryStringQueryBuilder.field(SearchDocumentFieldName.TITLE.getFieldName(), (float) 0.5)
                                .field(SearchDocumentFieldName.DESCRIPTION.getFieldName(), (float) 0.15)
                                ;
        
        for (final String contentCategoryFieldName : SearchFacetName.categoryFacetFields)
        {
            queryStringQueryBuilder.field(SearchDocumentFieldName.CATEGORIES_ARRAY.getFieldName() + "."
                    + contentCategoryFieldName, 1);
        }
        
        matchQueryBuilder = queryStringQueryBuilder;
    }
    
    if(searchCriteria.isUseBoostingFactor())
    {
        FunctionScoreQueryBuilder queryBuilder = new FunctionScoreQueryBuilder(matchQueryBuilder);
        ScoreFunctionBuilder scoreFunctionBuilder = new ScriptScoreFunctionBuilder().script(SearchDocumentFieldName
                .getCalculatedScoreScriptForBostFactor());
        queryBuilder.add(scoreFunctionBuilder);
        return queryBuilder;
    }

    return matchQueryBuilder;
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:41,代码来源:ProductQueryServiceImpl.java

示例8: 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());
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:15,代码来源:ElasticSearchTutPart2Test.java

示例9: 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());
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:16,代码来源:ElasticSearchTutPart2Test.java

示例10: 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());
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:30,代码来源:ElasticSearchTutPart2Test.java

示例11: 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);
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:37,代码来源:ElasticSearchTutPart3Test.java

示例12: 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());
        }
    }
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:35,代码来源:ElasticSearchTutPart3Test.java

示例13: 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());
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:34,代码来源:ElasticSearchTutPart3Test.java

示例14: 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());
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:35,代码来源:ElasticSearchTutPart3Test.java

示例15: 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());
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:37,代码来源:ElasticSearchTutPart5Test.java


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