本文整理汇总了Java中org.infinispan.query.Search.getSearchManager方法的典型用法代码示例。如果您正苦于以下问题:Java Search.getSearchManager方法的具体用法?Java Search.getSearchManager怎么用?Java Search.getSearchManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.infinispan.query.Search
的用法示例。
在下文中一共展示了Search.getSearchManager方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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);
}
示例8: 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));
}