org.apache.lucene.queries.TermsFilter Java Examples
The following examples show how to use
org.apache.lucene.queries.TermsFilter.
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
Source File: TermQueryPrefixTreeStrategy.java From incubator-retired-blur with Apache License 2.0 | 6 votes |
@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); }
Example #2
Source File: DefaultQueryBuilder.java From modernmt with Apache License 2.0 | 5 votes |
@Override 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); termsQuery.setMinimumNumberShouldMatch(minMatches); // Context filter TermsFilter contextFilter = makeContextFilter(builder, context); // Result return new FilteredQuery(termsQuery, contextFilter); }
Example #3
Source File: DefaultQueryBuilder.java From modernmt with Apache License 2.0 | 4 votes |
protected static TermsFilter makeContextFilter(DocumentBuilder builder, ContextVector context) { ArrayList<Term> terms = new ArrayList<>(context.size()); for (ContextVector.Entry entry : context) terms.add(builder.makeMemoryTerm(entry.memory.getId())); return new TermsFilter(terms); }
Example #4
Source File: XJoinQParserPlugin.java From BioSolr with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("unchecked") Filter makeFilter(String fname, Iterator<BytesRef> it) { return new TermsFilter(fname, IteratorUtils.toList(it)); }