Search in sources :

Example 21 with Item

use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.

the class SegmentSubstitutionTestCase method testSubstitutionAndNot.

public void testSubstitutionAndNot() {
    Item a = parseQuery("-firstsecond bc");
    Query q = new Query("?query=ignored&tracelevel=0&tracelevel.rules=0");
    q.getModel().getQueryTree().setRoot(a);
    assertSemantics("+bc -\"first third\"", q);
}
Also used : Item(com.yahoo.prelude.query.Item) Query(com.yahoo.search.Query)

Example 22 with Item

use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.

the class SegmentSubstitutionTestCase method testBasicSubstitution.

public void testBasicSubstitution() {
    Item a = parseQuery("firstsecond");
    Query q = new Query("?query=ignored&tracelevel=0&tracelevel.rules=0");
    q.getModel().getQueryTree().setRoot(a);
    assertSemantics("\"first third\"", q);
}
Also used : Item(com.yahoo.prelude.query.Item) Query(com.yahoo.search.Query)

Example 23 with Item

use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.

the class TextSerialize method parse.

public static Item parse(String serializedQuery) {
    try {
        ItemContext context = new ItemContext();
        Object result = new Parser(new StringReader(serializedQuery.replace("'", "\"")), new ItemFormHandler(), context).start();
        context.connectItems();
        if (!(result instanceof Item)) {
            throw new RuntimeException("The serialized query '" + serializedQuery + "' did not evaluate to an Item" + "(type = " + result.getClass() + ")");
        }
        return (Item) result;
    } catch (ParseException e) {
        throw new RuntimeException(e);
    } catch (TokenMgrError e) {
        throw new RuntimeException(e);
    }
}
Also used : ItemContext(com.yahoo.search.query.textserialize.item.ItemContext) Item(com.yahoo.prelude.query.Item) ItemFormHandler(com.yahoo.search.query.textserialize.item.ItemFormHandler) StringReader(java.io.StringReader) TokenMgrError(com.yahoo.search.query.textserialize.parser.TokenMgrError) ParseException(com.yahoo.search.query.textserialize.parser.ParseException) Parser(com.yahoo.search.query.textserialize.parser.Parser)

Example 24 with Item

use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.

the class Model method prepareRankFeaturesFromModel.

private void prepareRankFeaturesFromModel(Ranking ranking) {
    Item root = getQueryTree().getRoot();
    if (root != null) {
        List<Item> tagged = setUniqueIDs(root);
        addLabels(tagged, ranking);
        addConnectivityRankProperties(tagged, ranking);
        addSignificances(tagged, ranking);
    }
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) TaggableItem(com.yahoo.prelude.query.TaggableItem) Item(com.yahoo.prelude.query.Item)

Example 25 with Item

use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.

the class Model method addSignificances.

private void addSignificances(List<Item> candidates, Ranking ranking) {
    for (Item candidate : candidates) {
        TaggableItem t = (TaggableItem) candidate;
        if (!t.hasExplicitSignificance())
            continue;
        String name = "vespa.term." + t.getUniqueID() + ".significance";
        ranking.getProperties().put(name, String.valueOf(t.getSignificance()));
    }
}
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)

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