use of com.yahoo.net.URI in project vespa by vespa-engine.
the class FastHit method getUri.
/**
* Returns the explicitly set uri if available, returns "index:[source]/[partid]/[id]" otherwise
*
* @return uri of hit
*/
public URI getUri() {
URI uri = super.getId();
if (uri != null)
return uri;
// TODO: Remove, this should be one of the last vestiges of URL field magic
if (fields().containsKey("uri")) {
// trigger decoding
Object o = getField("uri");
setId(o.toString());
return super.getId();
}
return getIndexUri();
}
use of com.yahoo.net.URI in project vespa by vespa-engine.
the class FederationSearcherTest method custom_federation_target.
@Test
public void custom_federation_target() {
ComponentId targetSelectorId = ComponentId.fromString("TargetSelector");
ComponentRegistry<TargetSelector> targetSelectors = new ComponentRegistry<>();
targetSelectors.register(targetSelectorId, new TestTargetSelector());
FederationSearcher searcher = new FederationSearcher(new FederationConfig(new FederationConfig.Builder().targetSelector(targetSelectorId.toString())), new StrictContractsConfig(new StrictContractsConfig.Builder()), targetSelectors);
Result result = new Execution(searcher, Context.createContextStub()).search(new Query());
HitGroup myChainGroup = (HitGroup) result.hits().get(0);
assertThat(myChainGroup.getId(), is(new URI("source:myChain")));
assertThat(myChainGroup.get(0).getId(), is(new URI("myHit")));
}
use of com.yahoo.net.URI in project vespa by vespa-engine.
the class HitConverterTestCase method requireThatHitsAreConverted.
@Test
public void requireThatHitsAreConverted() {
HitConverter converter = new HitConverter(new MySearcher(), new Query());
Hit hit = converter.toSearchHit("default", new FS4Hit(1, createGlobalId(2), 3).setContext(new Hit("hit:ctx")));
assertNotNull(hit);
assertEquals(new URI("index:0/1/0/" + FastHit.asHexString(createGlobalId(2))), hit.getId());
hit = converter.toSearchHit("default", new FS4Hit(4, createGlobalId(5), 6).setContext(new Hit("hit:ctx")));
assertNotNull(hit);
assertEquals(new URI("index:0/4/0/" + FastHit.asHexString(createGlobalId(5))), hit.getId());
}
Aggregations