@Override public String getField() { return query.getField(); }
@Override public String getField() { return match.getField(); }
@Override public String getField() { return big.getField(); }
@Override public String getField() { return include.getField(); }
/** Construct a SpanNotQuery matching spans from <code>include</code> which * have no overlap with spans from <code>exclude</code> within * <code>pre</code> tokens before or <code>post</code> tokens of * <code>include</code>. Inversely, negative values for <code>pre</code> and/or * <code>post</code> allow a certain amount of overlap to occur. */ public SpanNotQuery(SpanQuery include, SpanQuery exclude, int pre, int post) { this.include = Objects.requireNonNull(include); this.exclude = Objects.requireNonNull(exclude); this.pre = pre; this.post = post; if (include.getField() != null && exclude.getField() != null && !include.getField().equals(exclude.getField())) throw new IllegalArgumentException("Clauses must have same field."); }
/** Adds a clause to this query */ private final void addClause(SpanQuery clause) { if (field == null) { field = clause.getField(); } else if (clause.getField() != null && !clause.getField().equals(field)) { throw new IllegalArgumentException("Clauses must have same field."); } this.clauses.add(clause); }
SpanContainQuery(SpanQuery big, SpanQuery little) { this.big = Objects.requireNonNull(big); this.little = Objects.requireNonNull(little); Objects.requireNonNull(big.getField()); Objects.requireNonNull(little.getField()); if (! big.getField().equals(little.getField())) { throw new IllegalArgumentException("big and little not same field"); } }
/** * Add a new clause */ public Builder addClause(SpanQuery clause) { if (Objects.equals(clause.getField(), field) == false) throw new IllegalArgumentException("Cannot add clause " + clause + " to SpanNearQuery for field " + field); this.clauses.add(clause); return this; }
/** Construct a SpanNearQuery. Matches spans matching a span from each * clause, with up to <code>slop</code> total unmatched positions between * them. * <br>When <code>inOrder</code> is true, the spans from each clause * must be in the same order as in <code>clauses</code> and must be non-overlapping. * <br>When <code>inOrder</code> is false, the spans from each clause * need not be ordered and may overlap. * @param clausesIn the clauses to find near each other, in the same field, at least 2. * @param slop The slop value * @param inOrder true if order is important */ public SpanNearQuery(SpanQuery[] clausesIn, int slop, boolean inOrder) { this.clauses = new ArrayList<>(clausesIn.length); for (SpanQuery clause : clausesIn) { if (this.field == null) { // check field this.field = clause.getField(); } else if (clause.getField() != null && !clause.getField().equals(field)) { throw new IllegalArgumentException("Clauses must have same field."); } this.clauses.add(clause); } this.slop = slop; this.inOrder = inOrder; }
private Similarity.SimWeight buildSimWeight(SpanQuery query, IndexSearcher searcher, Map<Term, TermContext> termContexts, float boost) throws IOException { if (termContexts == null || termContexts.size() == 0 || query.getField() == null) return null; TermStatistics[] termStats = new TermStatistics[termContexts.size()]; int i = 0; for (Term term : termContexts.keySet()) { termStats[i] = searcher.termStatistics(term, termContexts.get(term)); i++; } CollectionStatistics collectionStats = searcher.collectionStatistics(query.getField()); return similarity.computeWeight(boost, collectionStats, termStats); }
/** * Create a new SpanWeight * @param query the parent query * @param searcher the IndexSearcher to query against * @param termContexts a map of terms to termcontexts for use in building the similarity. May * be null if scores are not required * @throws IOException on error */ public SpanWeight(SpanQuery query, IndexSearcher searcher, Map<Term, TermContext> termContexts, float boost) throws IOException { super(query); this.field = query.getField(); this.similarity = searcher.getSimilarity(termContexts != null); this.simWeight = buildSimWeight(query, searcher, termContexts, boost); }
spanNearFieldName = queryFieldName(context, fieldName); } else { spanNearFieldName = ((SpanQuery) query).getField();
@Override public String getField() { return match.getField(); }
/** Construct a SpanNotQuery matching spans from <code>include</code> which * have no overlap with spans from <code>exclude</code>.*/ public SpanNotQuery(SpanQuery include, SpanQuery exclude) { this.include = include; this.exclude = exclude; if (!include.getField().equals(exclude.getField())) throw new IllegalArgumentException("Clauses must have same field."); }
/** Adds a clause to this query */ private final void addClause(SpanQuery clause) { if (field == null) { field = clause.getField(); } else if (clause.getField() != null && !clause.getField().equals(field)) { throw new IllegalArgumentException("Clauses must have same field."); } this.clauses.add(clause); }
SpanContainQuery(SpanQuery big, SpanQuery little) { this.big = Objects.requireNonNull(big); this.little = Objects.requireNonNull(little); Objects.requireNonNull(big.getField()); Objects.requireNonNull(little.getField()); if (! big.getField().equals(little.getField())) { throw new IllegalArgumentException("big and little not same field"); } }
SpanContainQuery(SpanQuery big, SpanQuery little) { this.big = Objects.requireNonNull(big); this.little = Objects.requireNonNull(little); Objects.requireNonNull(big.getField()); Objects.requireNonNull(little.getField()); if (! big.getField().equals(little.getField())) { throw new IllegalArgumentException("big and little not same field"); } }
/** * Add a new clause */ public Builder addClause(SpanQuery clause) { if (Objects.equals(clause.getField(), field) == false) throw new IllegalArgumentException("Cannot add clause " + clause + " to SpanNearQuery for field " + field); this.clauses.add(clause); return this; }
private Similarity.SimWeight buildSimWeight(SpanQuery query, IndexSearcher searcher, Map<Term, TermContext> termContexts, float boost) throws IOException { if (termContexts == null || termContexts.size() == 0 || query.getField() == null) return null; TermStatistics[] termStats = new TermStatistics[termContexts.size()]; int i = 0; for (Term term : termContexts.keySet()) { termStats[i] = searcher.termStatistics(term, termContexts.get(term)); i++; } CollectionStatistics collectionStats = searcher.collectionStatistics(query.getField()); return similarity.computeWeight(boost, collectionStats, termStats); }
public Scorer scorer(IndexReader reader) throws IOException { return new SpanScorer(query.getSpans(reader), this, query.getSimilarity(searcher), reader.norms(query.getField())); }