Search in sources :

Example 21 with IndexFacts

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

the class LegacyCombinator method search.

@Override
public Result search(Query query, Execution execution) {
    Set<QueryPart> pieces;
    Set<String> usedSources;
    IndexFacts indexFacts = execution.context().getIndexFacts();
    try {
        pieces = findQuerySnippets(query.properties());
    } catch (IllegalArgumentException e) {
        query.errors().add(ErrorMessage.createInvalidQueryParameter("LegacyCombinator got invalid parameters: " + e.getMessage()));
        return execution.search(query);
    }
    if (pieces.size() == 0) {
        return execution.search(query);
    }
    IndexFacts.Session session = indexFacts.newSession(query);
    Language language = query.getModel().getParsingLanguage();
    addAndItems(language, query, pieces, session, execution.context());
    addRankItems(language, query, pieces, session, execution.context());
    try {
        addNotItems(language, query, pieces, session, execution.context());
    } catch (IllegalArgumentException e) {
        query.errors().add(ErrorMessage.createInvalidQueryParameter("LegacyCombinator found only excluding terms, no including."));
        return execution.search(query);
    }
    query.trace("Adding extra query parts.", true, 2);
    return execution.search(query);
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) Language(com.yahoo.language.Language)

Example 22 with IndexFacts

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

the class NGramSearcher method search.

@Override
public Result search(Query query, Execution execution) {
    IndexFacts indexFacts = execution.context().getIndexFacts();
    // shortcut
    if (!indexFacts.hasNGramIndices())
        return execution.search(query);
    IndexFacts.Session session = indexFacts.newSession(query);
    boolean rewritten = rewriteToNGramMatching(query.getModel().getQueryTree().getRoot(), 0, session, query);
    if (rewritten)
        query.trace("Rewritten to n-gram matching", true, 2);
    Result result = execution.search(query);
    recombineNGrams(result.hits().deepIterator(), session);
    return result;
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) Result(com.yahoo.search.Result)

Example 23 with IndexFacts

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

the class NGramSearcher method fill.

@Override
public void fill(Result result, String summaryClass, Execution execution) {
    execution.fill(result, summaryClass);
    IndexFacts indexFacts = execution.context().getIndexFacts();
    if (indexFacts.hasNGramIndices())
        recombineNGrams(result.hits().deepIterator(), indexFacts.newSession(result.getQuery()));
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts)

Example 24 with IndexFacts

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

the class ParsingTester method createIndexFacts.

/**
 * Returns an unfrozen version of the IndexFacts this will use.
 * This can be used to add new indexes and passing the resulting IndexFacts to the constructor of this.
 */
public static IndexFacts createIndexFacts() {
    String indexInfoConfigID = "file:src/test/java/com/yahoo/prelude/query/parser/test/parseindexinfo.cfg";
    ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
    IndexInfoConfig config = getter.getConfig(indexInfoConfigID);
    return new IndexFacts(new IndexModel(config, (QrSearchersConfig) null));
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) ConfigGetter(com.yahoo.config.subscription.ConfigGetter) QrSearchersConfig(com.yahoo.container.QrSearchersConfig) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) IndexModel(com.yahoo.prelude.IndexModel)

Example 25 with IndexFacts

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

the class QueryCombinatorTestCase method testDefaultIndexWithoutQuery.

public void testDefaultIndexWithoutQuery() {
    Query q = new Query("?defidx.juhu=b");
    Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    assertEquals("NULL", q.getModel().getQueryTree().toString());
    q = new Query("?query=a&defidx.juhu=b");
    e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    assertEquals("a", q.getModel().getQueryTree().toString());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts)

Aggregations

IndexFacts (com.yahoo.prelude.IndexFacts)73 Query (com.yahoo.search.Query)41 Execution (com.yahoo.search.searchchain.Execution)34 Test (org.junit.Test)26 Index (com.yahoo.prelude.Index)22 IndexModel (com.yahoo.prelude.IndexModel)12 Result (com.yahoo.search.Result)8 ArrayList (java.util.ArrayList)8 List (java.util.List)8 SimpleLinguistics (com.yahoo.language.simple.SimpleLinguistics)7 SearchDefinition (com.yahoo.prelude.SearchDefinition)6 IndexInfoConfig (com.yahoo.search.config.IndexInfoConfig)6 Chain (com.yahoo.component.chain.Chain)5 Token (com.yahoo.prelude.query.parser.Token)5 Tokenizer (com.yahoo.prelude.query.parser.Tokenizer)5 ConfigGetter (com.yahoo.config.subscription.ConfigGetter)4 AndItem (com.yahoo.prelude.query.AndItem)4 WordItem (com.yahoo.prelude.query.WordItem)4 HashSet (java.util.HashSet)4 LinkedHashMap (java.util.LinkedHashMap)4