Java Code Examples for org.apache.lucene.queries.TermsFilter

The following examples show how to use org.apache.lucene.queries.TermsFilter. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
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);
Example 2
Source Project: modernmt   Source File:    License: Apache License 2.0 5 votes vote down vote up
public Query bestMatchingSuggestion(DocumentBuilder builder, Analyzer analyzer, UUID user, LanguageDirection direction, Sentence sentence, ContextVector context) {
    int length = sentence.getWords().length;
    int minMatches = length > SHORT_QUERY_SIZE ? Math.max(1, (int) (length * .5)) : length;

    // Content query
    BooleanQuery termsQuery = makeTermsQuery(builder, direction, sentence, analyzer);

    // Context filter
    TermsFilter contextFilter = makeContextFilter(builder, context);

    // Result
    return new FilteredQuery(termsQuery, contextFilter);
Example 3
Source Project: modernmt   Source File:    License: Apache License 2.0 4 votes vote down vote up
protected static TermsFilter makeContextFilter(DocumentBuilder builder, ContextVector context) {
    ArrayList<Term> terms = new ArrayList<>(context.size());
    for (ContextVector.Entry entry : context)
    return new TermsFilter(terms);
Example 4
Source Project: BioSolr   Source File:    License: Apache License 2.0 4 votes vote down vote up
Filter makeFilter(String fname, Iterator<BytesRef> it) {
  return new TermsFilter(fname, IteratorUtils.toList(it));