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


Java TermsFilter类代码示例

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


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

示例1: getFilter

import org.apache.lucene.queries.TermsFilter; //导入依赖的package包/类
@Override
public Filter getFilter(Element e) throws ParserException {
  List<BytesRef> terms = new ArrayList<>();
  String text = DOMUtils.getNonBlankTextOrFail(e);
  String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");

  TokenStream ts = null;
  try {
    ts = analyzer.tokenStream(fieldName, text);
    TermToBytesRefAttribute termAtt = ts.addAttribute(TermToBytesRefAttribute.class);
    BytesRef bytes = termAtt.getBytesRef();
    ts.reset();
    while (ts.incrementToken()) {
      termAtt.fillBytesRef();
      terms.add(BytesRef.deepCopyOf(bytes));
    }
    ts.end();
  }
  catch (IOException ioe) {
    throw new RuntimeException("Error constructing terms from index:" + ioe);
  } finally {
    IOUtils.closeWhileHandlingException(ts);
  }
  return new TermsFilter(fieldName, terms);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:TermsFilterBuilder.java

示例2: terms

import org.apache.lucene.queries.TermsFilter; //导入依赖的package包/类
/**
 * Returns a filter that forces a given field to be one of the given values
 */
public static Filter terms(final String field, final Collection<?> values) {
    if (CollectionUtils.isEmpty(values)) {
        return null;
    }
    final TermsFilter filter = new TermsFilter();
    int count = 0;
    for (final Object object : values) {
        final String term = object == null ? null : StringUtils.trimToNull("" + object);
        if (term != null) {
            /* todo addterm*/
            //filter.addTerm(new Term(field, term));
            count++;
        }
    }
    return count == 0 ? null : filter;
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:20,代码来源:Filters.java

示例3: addTerms

import org.apache.lucene.queries.TermsFilter; //导入依赖的package包/类
/**
 * Returns a filter that forces a given field to be one of the given values
 */
public void addTerms(final String field, final Collection<?> values) {
    if (CollectionUtils.isEmpty(values)) {
        return;
    }
    boolean used = false;
    final TermsFilter filter = new TermsFilter();
    for (final Object object : values) {
        final String term = CoercionHelper.coerce(String.class, object);
        if (StringUtils.isNotEmpty(term)) {
            /* todo addterm */
            //filter.addTerm(new Term(field, term));
            used = true;
        }
    }
    if (used) {
        add(filter);
    }
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:22,代码来源:Filters.java

示例4: makeFilter

import org.apache.lucene.queries.TermsFilter; //导入依赖的package包/类
@Override
public Filter makeFilter(SpatialArgs args) {
  final SpatialOperation op = args.getOperation();
  if (op != SpatialOperation.Intersects)
    throw new UnsupportedSpatialOperation(op);

  Shape shape = args.getShape();
  int detailLevel = grid.getLevelForDistance(args.resolveDistErr(ctx, distErrPct));
  List<Cell> cells = grid.getCells(shape, detailLevel,
      false,//no parents
      true);//simplify
  BytesRef[] terms = new BytesRef[cells.size()];
  int i = 0;
  for (Cell cell : cells) {
    terms[i++] = new BytesRef(cell.getTokenString());//TODO use cell.getTokenBytes()
  }
  return new TermsFilter(getFieldName(), terms);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TermQueryPrefixTreeStrategy.java

示例5: makeFilter

import org.apache.lucene.queries.TermsFilter; //导入依赖的package包/类
@Override
public Filter makeFilter(SpatialArgs args) {
  final SpatialOperation op = args.getOperation();
  if (op != SpatialOperation.Intersects)
    throw new UnsupportedSpatialOperation(op);

  Shape shape = args.getShape();
  int detailLevel = grid.getLevelForDistance(args.resolveDistErr(ctx, distErrPct));
  List<Node> cells = grid.getNodes(shape, detailLevel,
      false,//no parents
      true);//simplify
  BytesRef[] terms = new BytesRef[cells.size()];
  int i = 0;
  for (Node cell : cells) {
    terms[i++] = new BytesRef(cell.getTokenString());
  }
  return new TermsFilter(getFieldName(), terms);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:19,代码来源:TermQueryPrefixTreeStrategy.java

示例6: getFilter

import org.apache.lucene.queries.TermsFilter; //导入依赖的package包/类
@Override
public Filter getFilter(Element e) throws ParserException {
  List<BytesRef> terms = new ArrayList<BytesRef>();
  String text = DOMUtils.getNonBlankTextOrFail(e);
  String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");

  try {
    TokenStream ts = analyzer.tokenStream(fieldName, new StringReader(text));
    TermToBytesRefAttribute termAtt = ts.addAttribute(TermToBytesRefAttribute.class);
    Term term = null;
    BytesRef bytes = termAtt.getBytesRef();
    ts.reset();
    while (ts.incrementToken()) {
      termAtt.fillBytesRef();
      terms.add(BytesRef.deepCopyOf(bytes));
    }
    ts.end();
    ts.close();
  }
  catch (IOException ioe) {
    throw new RuntimeException("Error constructing terms from index:" + ioe);
  }
  return new TermsFilter(fieldName, terms);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:25,代码来源:TermsFilterBuilder.java

示例7: makeFilter

import org.apache.lucene.queries.TermsFilter; //导入依赖的package包/类
@Override
public Filter makeFilter(SpatialArgs args) {
  final SpatialOperation op = args.getOperation();
  if (op != SpatialOperation.Intersects)
    throw new UnsupportedSpatialOperation(op);

  Shape shape = args.getShape();
  int detailLevel = grid.getLevelForDistance(args.resolveDistErr(ctx, distErrPct));
  List<Cell> cells = grid.getCells(shape, detailLevel, false,// no parents
      true);// simplify
  BytesRef[] terms = new BytesRef[cells.size()];
  int i = 0;
  for (Cell cell : cells) {
    terms[i++] = new BytesRef(cell.getTokenString());
  }
  return new TermsFilter(getFieldName(), terms);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:18,代码来源:TermQueryPrefixTreeStrategy.java

示例8: makeFilter

import org.apache.lucene.queries.TermsFilter; //导入依赖的package包/类
@Override
public Filter makeFilter(SpatialArgs args) {
  final SpatialOperation op = args.getOperation();
  if (op != SpatialOperation.Intersects)
    throw new UnsupportedSpatialOperation(op);

  Shape shape = args.getShape();
  int detailLevel = grid.getLevelForDistance(args.resolveDistErr(ctx, distErrPct));
  List<Cell> cells = grid.getCells(shape, detailLevel,
      false,//no parents
      true);//simplify
  BytesRef[] terms = new BytesRef[cells.size()];
  int i = 0;
  for (Cell cell : cells) {
    terms[i++] = new BytesRef(cell.getTokenString());
  }
  return new TermsFilter(getFieldName(), terms);
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:19,代码来源:TermQueryPrefixTreeStrategy.java

示例9: getFilter

import org.apache.lucene.queries.TermsFilter; //导入依赖的package包/类
@Override
public Filter getFilter(Element e) throws ParserException {
  List<BytesRef> terms = new ArrayList<BytesRef>();
  String text = DOMUtils.getNonBlankTextOrFail(e);
  String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");

  TokenStream ts = null;
  try {
    ts = analyzer.tokenStream(fieldName, text);
    TermToBytesRefAttribute termAtt = ts.addAttribute(TermToBytesRefAttribute.class);
    BytesRef bytes = termAtt.getBytesRef();
    ts.reset();
    while (ts.incrementToken()) {
      termAtt.fillBytesRef();
      terms.add(BytesRef.deepCopyOf(bytes));
    }
    ts.end();
  }
  catch (IOException ioe) {
    throw new RuntimeException("Error constructing terms from index:" + ioe);
  } finally {
    IOUtils.closeWhileHandlingException(ts);
  }
  return new TermsFilter(fieldName, terms);
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:26,代码来源:TermsFilterBuilder.java

示例10: toFilter

import org.apache.lucene.queries.TermsFilter; //导入依赖的package包/类
public Filter toFilter () {
    // Regular expression
    if (this.regex)
        return new QueryWrapperFilter(
                new RegexpQuery(new org.apache.lucene.index.Term(
                        this.field, this.term)));

    // Simple term
    return new TermsFilter(
            new org.apache.lucene.index.Term(this.field, this.term));
}
 
开发者ID:KorAP,项目名称:Krill,代码行数:12,代码来源:CollectionBuilder.java

示例11: makeFilter

import org.apache.lucene.queries.TermsFilter; //导入依赖的package包/类
@Override
Filter makeFilter(String fname, BytesRef[] bytesRefs) {
  return new TermsFilter(fname, bytesRefs);
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:TermsQParserPlugin.java

示例12: makeFilter

import org.apache.lucene.queries.TermsFilter; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
Filter makeFilter(String fname, Iterator<BytesRef> it) {
  return new TermsFilter(fname, IteratorUtils.toList(it));
}
 
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:6,代码来源:XJoinQParserPlugin.java


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