use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class Model method addLabels.
private void addLabels(List<Item> candidates, Ranking ranking) {
for (Item candidate : candidates) {
String label = candidate.getLabel();
if (label != null) {
String name = "vespa.label." + label + ".id";
TaggableItem t = (TaggableItem) candidate;
ranking.getProperties().put(name, String.valueOf(t.getUniqueID()));
}
}
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class InputCheckingSearcher method repeatedConsecutiveTermsInPhraseCheck.
private void repeatedConsecutiveTermsInPhraseCheck(PhraseItem phrase) {
if (phrase.getItemCount() > MAX_REPEATED_CONSECUTIVE_TERMS_IN_PHRASE) {
String prev = null;
int repeatedCount = 0;
for (int i = 0; i < phrase.getItemCount(); ++i) {
Item item = phrase.getItem(i);
if (item instanceof TermItem) {
TermItem term = (TermItem) item;
String current = term.getIndexedString();
if (prev != null) {
if (prev.equals(current)) {
repeatedCount++;
if (repeatedCount >= MAX_REPEATED_CONSECUTIVE_TERMS_IN_PHRASE) {
repeatedConsecutiveTermsInPhraseRejections.add();
throw new IllegalArgumentException("More than " + MAX_REPEATED_CONSECUTIVE_TERMS_IN_PHRASE + " ocurrences of term '" + current + "' in a row detected in phrase : " + phrase.toString());
}
} else {
repeatedCount = 0;
}
}
prev = current;
} else {
prev = null;
repeatedCount = 0;
}
}
}
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class ParseTestCase method testPrefixWithWeight.
@Test
public void testPrefixWithWeight() {
Item root = tester.assertParsed("prefix*!200", "prefix*!200", Query.Type.ANY);
assertTrue(root instanceof PrefixItem);
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class ParseTestCase method testPlusesAndMinuses.
@Test
public void testPlusesAndMinuses() {
Item root = tester.assertParsed("\"a b c d d\"", "a+b+c+d--d", Query.Type.ANY);
assertTrue(root instanceof PhraseItem);
assertFalse(((PhraseItem) root).isExplicit());
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class ParseTestCase method testPrefixExtraSpace.
@Test
public void testPrefixExtraSpace() {
Item root = tester.assertParsed("prefix", "prefix *", Query.Type.ANY);
assertTrue(root instanceof WordItem);
}
Aggregations