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;
}
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;
}
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;
}
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());
}
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());
}
Aggregations