FulltextQuery newFt = new FulltextQuery(); if (ft.op == Op.AND || ft.op == Op.OR) { List<FulltextQuery> newTerms = new LinkedList<>(); boolean isPhrase = ft.isPhrase(); if (!isPhrase) { newFt = ft; FulltextQuery sft = new FulltextQuery(); sft.op = Op.WORD; sft.word = subword;
continue; FulltextQuery w = new FulltextQuery(); if (minus) { if (word.length() == 0) {
} else { String word = ft.word; if (ft.isPhrase()) { if (quotePhraseWords) { boolean first = true;
if (ft.isPhrase()) { return ft; newTerms.add(term); } else { // Op.WORD if (term.isPhrase()) { newTerms.add(term); FulltextQuery newFt = new FulltextQuery(); newFt.op = Op.AND; newFt.terms = newTerms;
protected static void translateFulltext(FulltextQuery ft, List<String> buf, boolean and) { if (ft.op == Op.OR) { for (FulltextQuery term : ft.terms) { // don't quote words for OR translateFulltext(term, buf, false); } } else if (ft.op == Op.AND) { for (FulltextQuery term : ft.terms) { // quote words for AND translateFulltext(term, buf, true); } } else { String neg; if (ft.op == Op.NOTWORD) { neg = "-"; } else { // Op.WORD neg = ""; } String word = ft.word.toLowerCase(); if (ft.isPhrase() || and) { buf.add(neg + '"' + word + '"'); } else { buf.add(neg + word); } } }
protected void endAnd() { // put negative words at the end List<FulltextQuery> pos = new LinkedList<FulltextQuery>(); List<FulltextQuery> neg = new LinkedList<FulltextQuery>(); for (FulltextQuery term : terms) { if (term.op == Op.NOTWORD) { neg.add(term); } else { pos.add(term); } } if (!pos.isEmpty()) { terms = pos; terms.addAll(neg); if (terms.size() == 1) { ft.terms.add(terms.get(0)); } else { FulltextQuery a = new FulltextQuery(); a.op = Op.AND; a.terms = terms; ft.terms.add(a); } } terms = new LinkedList<FulltextQuery>(); }
public static boolean hasPhrase(FulltextQuery ft) { if (ft.op == Op.AND || ft.op == Op.OR) { for (FulltextQuery term : ft.terms) { if (hasPhrase(term)) { return true; } } return false; } else { return ft.isPhrase(); } }