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


Java ChainedFilter类代码示例

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


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

示例1: getRangeQuery

import org.apache.lucene.queries.ChainedFilter; //导入依赖的package包/类
public Query getRangeQuery(QParser parser, SchemaField field, final CurrencyValue p1, final CurrencyValue p2, final boolean minInclusive, final boolean maxInclusive) {
  String currencyCode = (p1 != null) ? p1.getCurrencyCode() :
                        (p2 != null) ? p2.getCurrencyCode() : defaultCurrency;

  // ValueSourceRangeFilter doesn't check exists(), so we have to
  final Filter docsWithValues = new FieldValueFilter(getAmountField(field).getName());
  final Filter vsRangeFilter = new ValueSourceRangeFilter
    (new RawCurrencyValueSource(field, currencyCode, parser),
     p1 == null ? null : p1.getAmount() + "", 
     p2 == null ? null : p2.getAmount() + "",
     minInclusive, maxInclusive);
  final Filter docsInRange = new ChainedFilter
    (new Filter [] { docsWithValues, vsRangeFilter }, ChainedFilter.AND);

  return new SolrConstantScoreQuery(docsInRange);
  
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:CurrencyField.java

示例2: chain

import org.apache.lucene.queries.ChainedFilter; //导入依赖的package包/类
/**
 * Returns all filters in a OR operation
 */
private static Filter chain(final int logic, Filter... filters) {
    filters = normalize(filters);
    if (ArrayUtils.isEmpty(filters)) {
        return null;
    }
    return new ChainedFilter(filters, logic);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:11,代码来源:Filters.java

示例3: getDocIdSet

import org.apache.lucene.queries.ChainedFilter; //导入依赖的package包/类
@Override
public DocIdSet getDocIdSet(AtomicReaderContext context, final Bits acceptDocs) throws IOException {
  Bits docsWithField;
  if (field == null) {
    docsWithField = null;//all docs
  } else {
    //NOTE By using the FieldCache we re-use a cache
    // which is nice but loading it in this way might be slower than say using an
    // intersects filter against the world bounds. So do we add a method to the
    // strategy, perhaps?  But the strategy can't cache it.
    docsWithField = FieldCache.DEFAULT.getDocsWithField(context.reader(), field);

    final int maxDoc = context.reader().maxDoc();
    if (docsWithField.length() != maxDoc )
      throw new IllegalStateException("Bits length should be maxDoc ("+maxDoc+") but wasn't: "+docsWithField);

    if (docsWithField instanceof Bits.MatchNoBits) {
      return null;//match nothing
    } else if (docsWithField instanceof Bits.MatchAllBits) {
      docsWithField = null;//all docs
    }
  }

  //not so much a chain but a way to conveniently invert the Filter
  DocIdSet docIdSet = new ChainedFilter(new Filter[]{intersectsFilter}, ChainedFilter.ANDNOT).getDocIdSet(context, acceptDocs);
  return BitsFilteredDocIdSet.wrap(docIdSet, docsWithField);
}
 
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:DisjointSpatialFilter.java

示例4: testAND

import org.apache.lucene.queries.ChainedFilter; //导入依赖的package包/类
public void testAND() throws Exception {
    ChainedFilter chain = new ChainedFilter(new Filter[] { dateFilter, bobFilter }, ChainedFilter.AND);
    TopDocs hits = searcher.search(query, chain, 10);
    assertEquals("AND matches just Bob", MAX / 2, hits.totalHits);
    StoredDocument firstDoc = searcher.doc(hits.scoreDocs[0].doc);
    assertEquals("bob", firstDoc.get("owner"));
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:8,代码来源:ChainedFilterTest.java

示例5: testXOR

import org.apache.lucene.queries.ChainedFilter; //导入依赖的package包/类
public void testXOR() throws Exception {
    ChainedFilter chain = new ChainedFilter(new Filter[] { dateFilter, bobFilter }, ChainedFilter.XOR);
    TopDocs hits = searcher.search(query, chain, 10);
    assertEquals("XOR matches Sue", MAX / 2, hits.totalHits);
    StoredDocument firstDoc = searcher.doc(hits.scoreDocs[0].doc);
    assertEquals("sue", firstDoc.get("owner"));
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:8,代码来源:ChainedFilterTest.java

示例6: testANDNOT

import org.apache.lucene.queries.ChainedFilter; //导入依赖的package包/类
public void testANDNOT() throws Exception {
    ChainedFilter chain = new ChainedFilter(new Filter[] { dateFilter, sueFilter }, new int[] { ChainedFilter.AND,
            ChainedFilter.ANDNOT });

    TopDocs hits = searcher.search(query, chain, 10);
    assertEquals("ANDNOT matches just Bob", MAX / 2, hits.totalHits);
    StoredDocument firstDoc = searcher.doc(hits.scoreDocs[0].doc);
    assertEquals("bob", firstDoc.get("owner"));
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:10,代码来源:ChainedFilterTest.java

示例7: and

import org.apache.lucene.queries.ChainedFilter; //导入依赖的package包/类
/**
 * Returns all filters in a AND operation
 */
public static Filter and(final Filter... filters) {
    return chain(ChainedFilter.AND, filters);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:7,代码来源:Filters.java

示例8: andNot

import org.apache.lucene.queries.ChainedFilter; //导入依赖的package包/类
/**
 * Returns all filters in a ANDNOT operation
 */
public static Filter andNot(final Filter... filters) {
    return chain(ChainedFilter.ANDNOT, filters);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:7,代码来源:Filters.java

示例9: or

import org.apache.lucene.queries.ChainedFilter; //导入依赖的package包/类
/**
 * Returns all filters in a OR operation
 */
public static Filter or(final Filter... filters) {
    return chain(ChainedFilter.OR, filters);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:7,代码来源:Filters.java

示例10: testOR

import org.apache.lucene.queries.ChainedFilter; //导入依赖的package包/类
public void testOR() throws Exception {
    ChainedFilter chain = new ChainedFilter(new Filter[] { sueFilter, bobFilter });

    assertEquals("OR matches all", MAX, TestUtil.hitCount(searcher, query, chain));
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:6,代码来源:ChainedFilterTest.java


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