Search in sources :

Example 6 with Index

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

the class Tokenizer method determineCurrentIndex.

@SuppressWarnings({ "deprecation" })
private Index determineCurrentIndex(Index defaultIndex, IndexFacts.Session indexFacts) {
    int backtrack = tokens.size();
    int tokencnt = 0;
    for (int i = 1; i <= tokens.size(); i++) {
        backtrack = tokens.size() - i;
        Token lookAt = tokens.get(backtrack);
        if (lookAt.kind != WORD && lookAt.kind != UNDERSCORE && lookAt.kind != NUMBER && lookAt.kind != DOT) {
            // do not use this token
            backtrack++;
            break;
        }
        tokencnt++;
    }
    StringBuilder tmp = new StringBuilder();
    for (int i = 0; i < tokencnt; i++) {
        Token useToken = tokens.get(backtrack + i);
        tmp.append(useToken.image);
    }
    String indexName = tmp.toString();
    if (indexName.length() > 0) {
        String canonicIndexName = indexFacts.getCanonicName(indexName);
        Index index = indexFacts.getIndex(canonicIndexName);
        if (!index.isNull()) {
            indexLastExplicitlyChangedAt = tokens.size();
            return index;
        }
    }
    return defaultIndex;
}
Also used : Index(com.yahoo.prelude.Index)

Example 7 with Index

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

the class JuniperSearcherTestCase method createSearchDefinitionOne.

private SearchDefinition createSearchDefinitionOne() {
    SearchDefinition one = new SearchDefinition("one");
    Index dynteaser = new Index("dynteaser");
    dynteaser.setDynamicSummary(true);
    one.addIndex(dynteaser);
    Index bigteaser = new Index("bigteaser");
    dynteaser.setHighlightSummary(true);
    one.addIndex(bigteaser);
    Index otherteaser = new Index("otherteaser");
    otherteaser.setDynamicSummary(true);
    one.addIndex(otherteaser);
    return one;
}
Also used : Index(com.yahoo.prelude.Index) SearchDefinition(com.yahoo.prelude.SearchDefinition)

Example 8 with Index

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

the class LiteralBoostSearcherTestCase method createSearchDefinitionWithFields.

private SearchDefinition createSearchDefinitionWithFields(String name, boolean literalBoost) {
    SearchDefinition type = new SearchDefinition(name);
    Index defaultIndex = new Index("default");
    defaultIndex.setLiteralBoost(literalBoost);
    type.addIndex(defaultIndex);
    Index absoluteIndex = new Index("absolute");
    absoluteIndex.setLiteralBoost(literalBoost);
    type.addIndex(absoluteIndex);
    return type;
}
Also used : Index(com.yahoo.prelude.Index) SearchDefinition(com.yahoo.prelude.SearchDefinition)

Example 9 with Index

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

the class IndexFactsTestCase method assertExactIsWorking.

private void assertExactIsWorking(String indexName) {
    Index index = new Index(indexName);
    index.setExact(true, "^^^");
    IndexFacts indexFacts = createIndexFacts();
    indexFacts.addIndex("artist", index);
    Query query = new Query();
    query.getModel().getSources().add("artist");
    assertTrue(indexFacts.newSession(query).getIndex(indexName).isExact());
    Query q = newQuery("?query=" + indexName + ":foo...&search=artist", indexFacts);
    assertEquals(indexName + ":foo...", q.getModel().getQueryTree().getRoot().toString());
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) Query(com.yahoo.search.Query) Index(com.yahoo.prelude.Index)

Example 10 with Index

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

the class IndexFactsTestCase method testPredicateBounds.

@Test
public void testPredicateBounds() {
    Index index = new Index("a");
    assertEquals(Long.MIN_VALUE, index.getPredicateLowerBound());
    assertEquals(Long.MAX_VALUE, index.getPredicateUpperBound());
    index.addCommand("predicate-bounds [2..300]");
    assertEquals(2L, index.getPredicateLowerBound());
    assertEquals(300L, index.getPredicateUpperBound());
    index.addCommand("predicate-bounds [-20000..30000]");
    assertEquals(-20_000L, index.getPredicateLowerBound());
    assertEquals(30_000L, index.getPredicateUpperBound());
    index.addCommand("predicate-bounds [-40000000000..-300]");
    assertEquals(-40_000_000_000L, index.getPredicateLowerBound());
    assertEquals(-300L, index.getPredicateUpperBound());
    index.addCommand("predicate-bounds [..300]");
    assertEquals(Long.MIN_VALUE, index.getPredicateLowerBound());
    assertEquals(300L, index.getPredicateUpperBound());
    index.addCommand("predicate-bounds [2..]");
    assertEquals(2L, index.getPredicateLowerBound());
    assertEquals(Long.MAX_VALUE, index.getPredicateUpperBound());
}
Also used : Index(com.yahoo.prelude.Index) Test(org.junit.Test)

Aggregations

Index (com.yahoo.prelude.Index)36 IndexFacts (com.yahoo.prelude.IndexFacts)23 Test (org.junit.Test)13 SimpleLinguistics (com.yahoo.language.simple.SimpleLinguistics)7 Query (com.yahoo.search.Query)6 SearchDefinition (com.yahoo.prelude.SearchDefinition)5 Token (com.yahoo.prelude.query.parser.Token)5 Tokenizer (com.yahoo.prelude.query.parser.Tokenizer)5 Execution (com.yahoo.search.searchchain.Execution)4 JSONString (com.yahoo.prelude.hitfield.JSONString)2 XMLString (com.yahoo.prelude.hitfield.XMLString)2 CompositeItem (com.yahoo.prelude.query.CompositeItem)2 Hit (com.yahoo.search.result.Hit)2 List (java.util.List)2 Before (org.junit.Before)2 Chain (com.yahoo.component.chain.Chain)1 Language (com.yahoo.language.Language)1 StemMode (com.yahoo.language.process.StemMode)1 IndexModel (com.yahoo.prelude.IndexModel)1 FastHit (com.yahoo.prelude.fastsearch.FastHit)1