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


Java Search类代码示例

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


Search类属于org.infinispan.query包,在下文中一共展示了Search类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.infinispan.query.Search; //导入依赖的package包/类
public static void main(String[] args) {
   ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.indexing().index(Index.ALL)
      .addProperty("default.directory_provider", "ram")
      .addProperty("lucene_version", "LUCENE_CURRENT");
   // Construct a simple local cache manager with default configuration
   DefaultCacheManager cacheManager = new DefaultCacheManager(builder.build());
   // Obtain the default cache
   Cache<String, Person> cache = cacheManager.getCache();
   // Store some entries
   cache.put("person1", new Person("William", "Shakespeare"));
   cache.put("person2", new Person("William", "Wordsworth"));
   cache.put("person3", new Person("John", "Milton"));
   // Obtain a query factory for the cache
   QueryFactory queryFactory = Search.getQueryFactory(cache);
   // Construct a query
   Query query = queryFactory.from(Person.class).having("name").eq("William").toBuilder().build();
   // Execute the query
   List<Person> matches = query.list();
   // List the results
   matches.forEach(person -> System.out.printf("Match: %s", person));
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:25,代码来源:InfinispanQuery.java

示例2: getBeerByIbuBetween

import org.infinispan.query.Search; //导入依赖的package包/类
public List<Beer> getBeerByIbuBetween(double low, double high){
    SearchManager searchManager = Search.getSearchManager(cache);
    QueryBuilder qb = searchManager.buildQueryBuilderForClass(Beer.class).get();
    Query query = qb.bool()
            .must( qb.range().onField("ibu").above(low).createQuery())
            .must( qb.range().onField("ibu").below(high).createQuery())
            .createQuery();
    List<Beer> result = (List<Beer>)(List)searchManager.getQuery(query, Beer.class).list();
    return result;
}
 
开发者ID:briantward,项目名称:jdg-lab,代码行数:11,代码来源:IndexedCacheBeerService.java

示例3: getBeerByIbuBetweenIQ

import org.infinispan.query.Search; //导入依赖的package包/类
public List<Beer> getBeerByIbuBetweenIQ(double low, double high){
    QueryFactory queryFactory = Search.getQueryFactory(cache);
    org.infinispan.query.dsl.Query infinispanQuery =
            queryFactory.from(Beer.class)
                    .orderBy("ibu", SortOrder.ASC)
                    .having("ibu")
                    .between(low,high)
                    .build();
    return infinispanQuery.list();
}
 
开发者ID:briantward,项目名称:jdg-lab,代码行数:11,代码来源:IndexedCacheBeerService.java

示例4: getAllBeers

import org.infinispan.query.Search; //导入依赖的package包/类
public List<Beer> getAllBeers(boolean desc) {
    SearchManager searchManager = Search.getSearchManager(cache);
    QueryBuilder qb = searchManager.buildQueryBuilderForClass(Beer.class).get();
    Query query = qb.all().createQuery();
    CacheQuery cq = searchManager.getQuery(query); //cq is a CacheQuery wrapper of a Lucene query
    if(desc){
        Sort sort = new Sort(new SortField("id", SortField.Type.LONG));
        cq.sort(sort);
    }
    List<Beer> result = (List<Beer>)(List)cq.list();
    return result;
}
 
开发者ID:briantward,项目名称:jdg-lab,代码行数:13,代码来源:IndexedCacheBeerService.java

示例5: getBeerByFuzzyMatchDescription

import org.infinispan.query.Search; //导入依赖的package包/类
public List<Beer> getBeerByFuzzyMatchDescription(String description){
    SearchManager searchManager = Search.getSearchManager(cache);
    QueryBuilder qb = searchManager.buildQueryBuilderForClass(Beer.class).get();
    Query query = qb.keyword()
            .fuzzy()
            .withPrefixLength(1)
            .onField("description")
            .matching(description)
            .createQuery();
    List<Beer> items = (List<Beer>)(List)searchManager.getQuery(query, Beer.class).list();
    return items;
}
 
开发者ID:briantward,项目名称:jdg-lab,代码行数:13,代码来源:IndexedCacheBeerService.java

示例6: getBeerByWildcardDescription

import org.infinispan.query.Search; //导入依赖的package包/类
public List<Beer> getBeerByWildcardDescription(String description){
    SearchManager searchManager = Search.getSearchManager(cache);
    QueryBuilder qb = searchManager.buildQueryBuilderForClass(Beer.class).get();
    Query query = qb.keyword()
            .wildcard()
            .onField("description")
            .matching(description + "*")
            .createQuery();
    List<Beer> items = (List<Beer>)(List)searchManager.getQuery(query, Beer.class).list();
    return items;
}
 
开发者ID:briantward,项目名称:jdg-lab,代码行数:12,代码来源:IndexedCacheBeerService.java

示例7: getBeerByIbuBetween

import org.infinispan.query.Search; //导入依赖的package包/类
public List<Beer> getBeerByIbuBetween(double low, double high){

        SearchManager searchManager = Search.getSearchManager(cache);
        QueryBuilder qb = searchManager.buildQueryBuilderForClass(Beer.class).get();
        Query query = qb.bool()
                .must( qb.range().onField("ibu").above(low).createQuery())
                .must( qb.range().onField("ibu").below(high).createQuery())
                .createQuery();
        List<Beer> result = (List<Beer>)(List)searchManager.getQuery(query, Beer.class).list();
        return result;
    }
 
开发者ID:briantward,项目名称:jdg-lab,代码行数:12,代码来源:CacheBeerService.java

示例8: getAllBeers

import org.infinispan.query.Search; //导入依赖的package包/类
public List<Beer> getAllBeers(boolean desc) {
    QueryFactory queryFactory = Search.getQueryFactory(cache);
    org.infinispan.query.dsl.QueryBuilder infinispanQueryBuilder =
            queryFactory.from(Beer.class);

    if(desc){
        infinispanQueryBuilder.orderBy("id", SortOrder.DESC);
    }
    org.infinispan.query.dsl.Query infinispanQuery = infinispanQueryBuilder.build();
    return infinispanQuery.list();
}
 
开发者ID:briantward,项目名称:jdg-lab,代码行数:12,代码来源:CacheBeerService.java

示例9: getBeerByWildcardDescription

import org.infinispan.query.Search; //导入依赖的package包/类
public List<Beer> getBeerByWildcardDescription(String description){
    QueryFactory queryFactory = Search.getQueryFactory(cache);
    org.infinispan.query.dsl.Query infinispanQuery =
            queryFactory.from(Beer.class)
                    .having("description")
                    .like("%" + description + "%")
                    .build();
    return infinispanQuery.list();
}
 
开发者ID:briantward,项目名称:jdg-lab,代码行数:10,代码来源:CacheBeerService.java

示例10: InventoryServiceIspn

import org.infinispan.query.Search; //导入依赖的package包/类
InventoryServiceIspn(Cache<String, Object> resource, Cache<String, Object> resourceType, String configPath, InventoryStatsMBean inventoryStatsMBean, ScrapeConfig scrapeConfig, File scrapeLocation) {
    this.resource = resource;
    this.resourceType = resourceType;
    qResource = Search.getQueryFactory(resource);
    qResourceType = Search.getQueryFactory(resourceType);
    this.configPath = Paths.get(configPath);
    this.inventoryStatsMBean = inventoryStatsMBean;
    this.scrapeConfig = scrapeConfig;
    this.scrapeLocation = scrapeLocation;
}
 
开发者ID:hawkular,项目名称:hawkular-commons,代码行数:11,代码来源:InventoryServiceIspn.java

示例11: init

import org.infinispan.query.Search; //导入依赖的package包/类
public void init() {
    backend = IspnCacheManager.getCacheManager().getCache("backend");
    if (backend == null) {
        log.error("Ispn backend cache not found. Check configuration.");
        throw new RuntimeException("backend cache not found");
    }
    queryFactory = Search.getQueryFactory(backend);
}
 
开发者ID:hawkular,项目名称:hawkular-alerts,代码行数:9,代码来源:IspnActionsServiceImpl.java

示例12: performSearch

import org.infinispan.query.Search; //导入依赖的package包/类
private static List<Object> performSearch(Condition where, String cacheName, ObjectConnection connection)
		throws TranslatorException {
	
	LogManager.logTrace(LogConstants.CTX_CONNECTOR,
			"Using Lucene Searching."); //$NON-NLS-1$
	
	Class<?> type = connection.getType(cacheName);
	
	//Map<?, ?> cache, 
	SearchManager searchManager = Search
			.getSearchManager((Cache<?, ?>) connection.getCacheContainer().getCache(cacheName) );

	QueryBuilder queryBuilder = searchManager.buildQueryBuilderForClass(type).get();

	BooleanJunction<BooleanJunction> junction = queryBuilder.bool();
	boolean createdQueries = buildQueryFromWhereClause(where,
			junction, queryBuilder);

	Query query = null;
	if (createdQueries) {
		query = junction.createQuery();
		
	} else {
		query = queryBuilder.all().createQuery();
	}

	CacheQuery cacheQuery = searchManager.getQuery(query, type); // rootNodeType

	List<Object> results = cacheQuery.list();
	if (results == null || results.isEmpty()) {
		return Collections.emptyList();
	}

	return results;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:36,代码来源:LuceneSearch.java

示例13: createQueryAdapter

import org.infinispan.query.Search; //导入依赖的package包/类
public <T> QueryAdapter<T> createQueryAdapter(Class<T> entityClass) {
    SearchManager searchManager = Search.getSearchManager(getCache(entityClass));
    return new InfinispanEmbeddedQueryAdapter<>(searchManager);
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:5,代码来源:InfinispanEmbeddedDatasourceMapper.java

示例14: testIndexingWithWrapper

import org.infinispan.query.Search; //导入依赖的package包/类
@Test
public void testIndexingWithWrapper() throws Exception {
   User user = User.newBuilder().build();
   user.setName("Alice");
   user.setFavoriteNumber(12);
   addToCache(user);

   final HashMap<String,String> hardDrives
         = new HashMap<String, String>() {{put("STCD00502", "SEAGATE");put("STA045M", "SEAGATE");}};
   DeviceList deviceList = DeviceList.newBuilder().build();
   deviceList.setDevices(new ArrayList<Map<String, String>>() {{
      add(hardDrives);
   }});
   deviceList.setName("my devices");
   addToCache(deviceList);

   WebPage page = WebPage.newBuilder().build();
   page.setKey("http://www.test.com");
   Map<String,String> outlinks = new HashMap<>();
   outlinks.put("1", "http://www.example.com");
   page.setOutlinks(outlinks);
   addToCache(page);

   SearchManager sm = Search.getSearchManager(cache);

   Query luceneQuery = sm.buildQueryBuilderForClass(GenericData.Record.class)
         .get()
         .keyword()
         .onField("name")
         .ignoreFieldBridge()
         .ignoreAnalyzer()
         .matching("Alice")
         .createQuery();
   List<Object> list = sm.getQuery(luceneQuery).list();
   assertEquals(1, list.size());
   assertEquals(list.get(0), toGeneric(user));

   luceneQuery = NumericRangeQuery.newIntRange("favorite_number", 8, 0, 12, true, true);
   list = sm.getQuery(luceneQuery).list();
   assertEquals(1, list.size());
   assertEquals(list.get(0), toGeneric(user));

   luceneQuery = sm.buildQueryBuilderForClass(GenericData.Record.class)
         .get()
         .keyword()
         .onField("name")
         .ignoreFieldBridge()
         .ignoreAnalyzer()
         .matching("Bob")
         .createQuery();
   list = sm.getQuery(luceneQuery).list();
   assertEquals(0, list.size());

   luceneQuery = sm.buildQueryBuilderForClass(GenericData.Record.class)
         .get()
         .keyword()
         .onField("devices" + Support.DELIMITER+"0")
               .ignoreFieldBridge()
               .ignoreAnalyzer()
         .matching("STCD00502" + Support.DELIMITER + "SEAGATE")
         .createQuery();
   list = sm.getQuery(luceneQuery).list();
   assertEquals(1, list.size());
   assertEquals(list.get(0),toGeneric(deviceList));

   luceneQuery = sm.buildQueryBuilderForClass(GenericData.Record.class)
         .get()
         .keyword()
         .onField("outlinks")
               .ignoreFieldBridge()
               .ignoreAnalyzer()
               .matching("1" + Support.DELIMITER+"http://www.example.com")
               .createQuery();
   list = sm.getQuery(luceneQuery).list();
   assertEquals(1,list.size());
   assertEquals(list.get(0),toGeneric(page));
}
 
开发者ID:leads-project,项目名称:infinispan-avro,代码行数:78,代码来源:AvroWrapperIndexingTest.java

示例15: getQueryBuilder

import org.infinispan.query.Search; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
	private static QueryBuilder getQueryBuilder(String cacheName, ObjectConnection conn) throws TranslatorException {
		
		Cache c = (Cache) conn.getCacheContainer().getCache(cacheName);
		
		// changed from 8.7.x (Infin. 6.1) to
		// upstream where only Infin  6.0 is available
		QueryFactory qf = Search.getSearchManager(c).getQueryFactory();
//		QueryFactory qf = Search.getQueryFactory(c);  
			
		Class<?> type = conn.getType(cacheName);
	    		  
	    QueryBuilder qb = qf.from(type);

	    return qb;
	}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:17,代码来源:DSLSearch.java


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