/** * Merges two matches. * * @param i1 first item * @param i2 second item */ private static void and(final FTNode i1, final FTNode i2) { final FTMatches all = new FTMatches((byte) Math.max(i1.matches().pos, i2.matches().pos)); for (final FTMatch s1 : i1.matches()) { for (final FTMatch s2 : i2.matches()) { all.add(new FTMatch(s1.size() + s2.size()).add(s1).add(s2)); } } i1.score(Scoring.avg(i1.score() + i2.score(), 2)); i1.matches(all); }
@Override public FTNode item(final QueryContext qc, final InputInfo ii) throws QueryException { if (pos == 0) pos = ++qc.ftPos; matches.reset(pos); final int c = contains(qc); if (c == 0) matches.size(0); // scoring: include number of tokens for calculations return new FTNode(matches, c == 0 ? 0 : Scoring.word(c, qc.ftToken.count())); }
/** * Adds a match. * * @param s start position * @param e end position */ void add(final int s, final int e) { if (!first && (mode == FTMode.ALL || mode == FTMode.ALL_WORDS)) matches.and(s, e); else matches.or(s, e); }