Search in sources :

Example 26 with Item

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()));
        }
    }
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) TaggableItem(com.yahoo.prelude.query.TaggableItem) Item(com.yahoo.prelude.query.Item) TaggableItem(com.yahoo.prelude.query.TaggableItem)

Example 27 with Item

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;
            }
        }
    }
}
Also used : TermItem(com.yahoo.prelude.query.TermItem) CompositeItem(com.yahoo.prelude.query.CompositeItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) Item(com.yahoo.prelude.query.Item) WordItem(com.yahoo.prelude.query.WordItem) TermItem(com.yahoo.prelude.query.TermItem)

Example 28 with Item

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);
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) PhraseSegmentItem(com.yahoo.prelude.query.PhraseSegmentItem) PrefixItem(com.yahoo.prelude.query.PrefixItem) Item(com.yahoo.prelude.query.Item) SuffixItem(com.yahoo.prelude.query.SuffixItem) IntItem(com.yahoo.prelude.query.IntItem) OrItem(com.yahoo.prelude.query.OrItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) SubstringItem(com.yahoo.prelude.query.SubstringItem) AndItem(com.yahoo.prelude.query.AndItem) RankItem(com.yahoo.prelude.query.RankItem) WordItem(com.yahoo.prelude.query.WordItem) NotItem(com.yahoo.prelude.query.NotItem) PrefixItem(com.yahoo.prelude.query.PrefixItem) Test(org.junit.Test)

Example 29 with Item

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());
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) PhraseSegmentItem(com.yahoo.prelude.query.PhraseSegmentItem) PrefixItem(com.yahoo.prelude.query.PrefixItem) Item(com.yahoo.prelude.query.Item) SuffixItem(com.yahoo.prelude.query.SuffixItem) IntItem(com.yahoo.prelude.query.IntItem) OrItem(com.yahoo.prelude.query.OrItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) SubstringItem(com.yahoo.prelude.query.SubstringItem) AndItem(com.yahoo.prelude.query.AndItem) RankItem(com.yahoo.prelude.query.RankItem) WordItem(com.yahoo.prelude.query.WordItem) NotItem(com.yahoo.prelude.query.NotItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) Test(org.junit.Test)

Example 30 with Item

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);
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) PhraseSegmentItem(com.yahoo.prelude.query.PhraseSegmentItem) PrefixItem(com.yahoo.prelude.query.PrefixItem) Item(com.yahoo.prelude.query.Item) SuffixItem(com.yahoo.prelude.query.SuffixItem) IntItem(com.yahoo.prelude.query.IntItem) OrItem(com.yahoo.prelude.query.OrItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) SubstringItem(com.yahoo.prelude.query.SubstringItem) AndItem(com.yahoo.prelude.query.AndItem) RankItem(com.yahoo.prelude.query.RankItem) WordItem(com.yahoo.prelude.query.WordItem) NotItem(com.yahoo.prelude.query.NotItem) WordItem(com.yahoo.prelude.query.WordItem) Test(org.junit.Test)

Aggregations

Item (com.yahoo.prelude.query.Item)116 AndItem (com.yahoo.prelude.query.AndItem)85 CompositeItem (com.yahoo.prelude.query.CompositeItem)82 WordItem (com.yahoo.prelude.query.WordItem)73 PhraseItem (com.yahoo.prelude.query.PhraseItem)66 NotItem (com.yahoo.prelude.query.NotItem)62 RankItem (com.yahoo.prelude.query.RankItem)60 SubstringItem (com.yahoo.prelude.query.SubstringItem)60 Test (org.junit.Test)58 OrItem (com.yahoo.prelude.query.OrItem)57 PrefixItem (com.yahoo.prelude.query.PrefixItem)53 SuffixItem (com.yahoo.prelude.query.SuffixItem)53 IntItem (com.yahoo.prelude.query.IntItem)52 PhraseSegmentItem (com.yahoo.prelude.query.PhraseSegmentItem)51 NullItem (com.yahoo.prelude.query.NullItem)24 Query (com.yahoo.search.Query)22 EquivItem (com.yahoo.prelude.query.EquivItem)14 NearItem (com.yahoo.prelude.query.NearItem)14 ExactStringItem (com.yahoo.prelude.query.ExactStringItem)12 IndexedItem (com.yahoo.prelude.query.IndexedItem)12