Search in sources :

Example 6 with URI

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();
}
Also used : URI(com.yahoo.net.URI)

Example 7 with URI

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")));
}
Also used : FederationSearcher(com.yahoo.search.federation.FederationSearcher) Query(com.yahoo.search.Query) URI(com.yahoo.net.URI) Result(com.yahoo.search.Result) StrictContractsConfig(com.yahoo.search.federation.StrictContractsConfig) Execution(com.yahoo.search.searchchain.Execution) ComponentRegistry(com.yahoo.component.provider.ComponentRegistry) TargetSelector(com.yahoo.search.federation.selection.TargetSelector) ComponentId(com.yahoo.component.ComponentId) FederationConfig(com.yahoo.search.federation.FederationConfig) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Example 8 with URI

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());
}
Also used : FS4Hit(com.yahoo.searchlib.aggregation.FS4Hit) FS4Hit(com.yahoo.searchlib.aggregation.FS4Hit) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) VdsHit(com.yahoo.searchlib.aggregation.VdsHit) Query(com.yahoo.search.Query) URI(com.yahoo.net.URI) Test(org.junit.Test)

Aggregations

URI (com.yahoo.net.URI)8 Query (com.yahoo.search.Query)4 Result (com.yahoo.search.Result)3 ResultBuilder (com.yahoo.search.federation.vespa.ResultBuilder)2 Test (org.junit.Test)2 ComponentId (com.yahoo.component.ComponentId)1 ComponentRegistry (com.yahoo.component.provider.ComponentRegistry)1 FastHit (com.yahoo.prelude.fastsearch.FastHit)1 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)1 FederationConfig (com.yahoo.search.federation.FederationConfig)1 FederationSearcher (com.yahoo.search.federation.FederationSearcher)1 StrictContractsConfig (com.yahoo.search.federation.StrictContractsConfig)1 TargetSelector (com.yahoo.search.federation.selection.TargetSelector)1 ErrorHit (com.yahoo.search.result.ErrorHit)1 ErrorMessage (com.yahoo.search.result.ErrorMessage)1 Hit (com.yahoo.search.result.Hit)1 HitGroup (com.yahoo.search.result.HitGroup)1 Execution (com.yahoo.search.searchchain.Execution)1 FS4Hit (com.yahoo.searchlib.aggregation.FS4Hit)1 VdsHit (com.yahoo.searchlib.aggregation.VdsHit)1