use of com.yahoo.search.Query in project vespa by vespa-engine.
the class PosSearcherTestCase method testInvalidInput.
/**
* Tests input parameters that should report errors.
*/
@Test
public void testInvalidInput() {
PosSearcher searcher = new PosSearcher();
Result result;
Query q = new Query();
q.properties().set("pos.ll", "NE74.14;E14.48");
result = doSearch(searcher, q, 0, 10);
assertEquals("Error in pos parameters: Unable to parse lat/long string 'NE74.14;E14.48': already set direction once, cannot add direction: E", ((ErrorHit) result.hits().get(0)).errors().iterator().next().getDetailedMessage());
q = new Query();
q.properties().set("pos.ll", "NE74.14;E14.48");
q.properties().set("pos.xy", "82400, 72800");
result = doSearch(searcher, q, 0, 10);
assertEquals("Error in pos parameters: Cannot handle both lat/long and xy coords at the same time", ((ErrorHit) result.hits().get(0)).errors().iterator().next().getDetailedMessage());
}
use of com.yahoo.search.Query in project vespa by vespa-engine.
the class PosSearcherTestCase method testBasics.
/**
* Tests basic lat/long input.
*/
@Test
public void testBasics() {
Query q = new Query();
q.properties().set("pos.ll", "N0;E0");
doSearch(searcher, q, 0, 10);
assertEquals("(2,0,0,450668,0,1,0,4294967295)", q.getRanking().getLocation().toString());
q = new Query();
q.properties().set("pos.ll", "N60;E30");
doSearch(searcher, q, 0, 10);
assertEquals("(2,30000000,60000000,450668,0,1,0,2147483647)", q.getRanking().getLocation().toString());
}
use of com.yahoo.search.Query in project vespa by vespa-engine.
the class PosSearcherTestCase method testBoundingBox.
/**
* Tests basic bounding box input.
*/
@Test
public void testBoundingBox() {
Query q = new Query();
q.properties().set("pos.bb", "n=51.9,s=50.2,e=0.34,w=-10.01");
doSearch(searcher, q, 0, 10);
assertEquals("[2,-10010000,50200000,340000,51900000]", q.getRanking().getLocation().toString());
q = new Query();
q.properties().set("pos.bb", "n=0,s=0,e=123.456789,w=-123.456789");
doSearch(searcher, q, 0, 10);
assertEquals("[2,-123456789,0,123456789,0]", q.getRanking().getLocation().toString());
q = new Query();
q.properties().set("pos.bb", "n=12.345678,s=-12.345678,e=0,w=0");
doSearch(searcher, q, 0, 10);
assertEquals("[2,0,-12345678,0,12345678]", q.getRanking().getLocation().toString());
q = new Query();
q.properties().set("pos.bb", "n=0.000001,s=-0.000001,e=0.000001,w=-0.000001");
doSearch(searcher, q, 0, 10);
assertEquals("[2,-1,-1,1,1]", q.getRanking().getLocation().toString());
}
use of com.yahoo.search.Query in project vespa by vespa-engine.
the class QueryValidatingSearcherTestCase method testBasic.
public void testBasic() {
// Setup
Map<Searcher, Searcher> chained = new HashMap<>();
Query query = new Query("?query=test");
Result result = new Result(query);
result.hits().add(new Hit("ymail://1111111111/AQAAAP7JgwEAj6XjQQAAAO/+ggA=", 950));
Searcher validator = new QueryValidatingSearcher();
DocumentSourceSearcher source = new DocumentSourceSearcher();
chained.put(validator, source);
source.addResult(query, result);
// Exercise
Result returnedResult = doSearch(validator, query, 0, 10, chained);
// Validate
assertEquals(1, returnedResult.getHitCount());
assertNull(returnedResult.hits().getError());
returnedResult = doSearch(validator, query, 0, 1001, chained);
assertEquals(0, returnedResult.getConcreteHitCount());
assertEquals(4, returnedResult.hits().getError().getCode());
returnedResult = doSearch(validator, query, 1001, 10, chained);
assertEquals(0, returnedResult.getConcreteHitCount());
assertEquals(4, returnedResult.hits().getError().getCode());
}
use of com.yahoo.search.Query in project vespa by vespa-engine.
the class AutomataTestCase method testAutomataRuleBase.
public void testAutomataRuleBase() throws Exception {
RuleBase ruleBase = searcher.getDefaultRuleBase();
assertEquals(RuleBase.class, ruleBase.getClass());
assertTrue(ruleBase.getSource().endsWith(root + "automatarules.sr"));
assertEquals(root + "semantics.fsa", ruleBase.getAutomataFile());
Query query = new Query("?query=sony+digital+camera");
ruleBase.analyze(query, 0);
assertEquals("RANK (AND sony digital camera) dsp1:sony dsp5:digicamera", query.getModel().getQueryTree().getRoot().toString());
query = new Query("?query=sony+digital+camera&rules.reload");
ruleBase = searcher.getDefaultRuleBase();
assertTrue(ruleBase.getSource().endsWith(root + "automatarules.sr"));
assertEquals(root + "semantics.fsa", ruleBase.getAutomataFile());
ruleBase.analyze(query, 0);
assertEquals("RANK (AND sony digital camera) dsp1:sony dsp5:digicamera", query.getModel().getQueryTree().getRoot().toString());
}
Aggregations