Search in sources :

Example 1 with URI

use of com.yahoo.net.URI in project vespa by vespa-engine.

the class FastHit method getIndexUri.

/**
 * The uri of the index location of this hit ("index:[source]/[partid]/[id]").
 * This is the uri if no other uri is assigned
 *
 * @return uri to the index.
 */
public URI getIndexUri() {
    if (indexUri != null)
        return indexUri;
    String rowString = "-";
    if (useRowInIndexUri)
        rowString = String.valueOf(getRow());
    indexUri = new URI("index:" + getSourceNumber() + "/" + getColumn() + "/" + rowString + "/" + asHexString(getGlobalId()));
    return indexUri;
}
Also used : URI(com.yahoo.net.URI)

Example 2 with URI

use of com.yahoo.net.URI in project vespa by vespa-engine.

the class Result method trace.

/**
 * Adds a context message to this query containing the entire content of this result,
 * if tracelevel is 5 or more.
 *
 * @param name the name of the searcher instance returning this result
 */
public void trace(String name) {
    if (hits().getQuery().getTraceLevel() < 5) {
        return;
    }
    StringBuilder hitBuffer = new StringBuilder(name);
    hitBuffer.append(" returns:\n");
    int counter = 0;
    for (Iterator<Hit> i = hits.unorderedIterator(); i.hasNext(); ) {
        Hit hit = i.next();
        if (hit.isMeta())
            continue;
        hitBuffer.append("  #: ");
        hitBuffer.append(counter);
        traceExtraHitProperties(hitBuffer, hit);
        hitBuffer.append(", relevancy: ");
        hitBuffer.append(hit.getRelevance());
        hitBuffer.append(", addno: ");
        hitBuffer.append(hit.getAddNumber());
        hitBuffer.append(", source: ");
        hitBuffer.append(hit.getSource());
        hitBuffer.append(", uri: ");
        URI uri = hit.getId();
        if (uri != null) {
            hitBuffer.append(uri.getHost());
        } else {
            hitBuffer.append("(no uri)");
        }
        hitBuffer.append("\n");
        counter++;
    }
    if (counter == 0) {
        hitBuffer.append("(no hits)\n");
    }
    hits.getQuery().trace(hitBuffer.toString(), false, 5);
}
Also used : URI(com.yahoo.net.URI)

Example 3 with URI

use of com.yahoo.net.URI in project vespa by vespa-engine.

the class ResultBuilderTestCase method testSimpleResult.

public void testSimpleResult() {
    boolean gotErrorDetails = false;
    ResultBuilder r = new ResultBuilder();
    Result res = r.parse("file:src/test/java/com/yahoo/prelude/searcher/test/testhit.xml", new Query("?query=a"));
    assertEquals(3, res.getConcreteHitCount());
    assertEquals(4, res.getHitCount());
    ErrorHit e = (ErrorHit) res.hits().get(0);
    // is no way of nuking an existing error if the details exist.
    for (Iterator<?> i = e.errorIterator(); i.hasNext(); ) {
        ErrorMessage err = (ErrorMessage) i.next();
        assertEquals(5, err.getCode());
        String details = err.getDetailedMessage();
        if (details != null) {
            gotErrorDetails = true;
            assertEquals("An error as ordered", details.trim());
        }
    }
    assertTrue("Error details are missing", gotErrorDetails);
    assertEquals(new URI("http://def"), res.hits().get(1).getId());
    assertEquals("test/stuff\\tsome/other", res.hits().get(2).getField("category"));
    assertEquals("<field>habla</field>" + "<hi>blbl</hi><br />&lt;&gt;&amp;fdlkkgj&lt;/field&gt;;lk<a b=\"1\" c=\"2\" />" + "<x><y><z /></y></x>", res.hits().get(3).getField("annoying").toString());
}
Also used : ResultBuilder(com.yahoo.search.federation.vespa.ResultBuilder) Query(com.yahoo.search.Query) ErrorHit(com.yahoo.search.result.ErrorHit) ErrorMessage(com.yahoo.search.result.ErrorMessage) URI(com.yahoo.net.URI) Result(com.yahoo.search.Result)

Example 4 with URI

use of com.yahoo.net.URI in project vespa by vespa-engine.

the class ResultBuilderTestCase method testWeirdDocumentID.

public void testWeirdDocumentID() {
    ResultBuilder r = new ResultBuilder();
    Result res = r.parse("file:src/test/java/com/yahoo/search/federation/vespa/test/idhits.xml", new Query("?query=a"));
    assertNull(res.hits().getError());
    assertEquals(3, res.hits().size());
    assertEquals(new URI("nalle"), res.hits().get(0).getId());
    assertEquals(new URI("tralle"), res.hits().get(1).getId());
    assertEquals(new URI("kalle"), res.hits().get(2).getId());
}
Also used : ResultBuilder(com.yahoo.search.federation.vespa.ResultBuilder) Query(com.yahoo.search.Query) URI(com.yahoo.net.URI) Result(com.yahoo.search.Result)

Example 5 with URI

use of com.yahoo.net.URI in project vespa by vespa-engine.

the class HitGroup method get.

/**
 * Returns the hit with the given id, or null if there is no hit with this id
 * in this group or any subgroup.
 * This method is o(min(number of nested hits in this result,depth)).
 *
 * @param id the id of the hit to return from this or any nested group
 * @param depth the max depth to recurse into nested groups: -1: Recurse infinitely deep, 0: Only look at hits in
 *        the list of this group, 1: Look at hits in this group, and the hits of any immediate nested HitGroups,
 *        etc.
 * @return The hit, or null if not found.
 */
public Hit get(URI id, int depth) {
    updateHits();
    for (Iterator<Hit> i = unorderedIterator(); i.hasNext(); ) {
        Hit hit = i.next();
        URI hitUri = hit.getId();
        if (hitUri != null && hitUri.equals(id)) {
            return hit;
        }
        if (hit instanceof HitGroup && depth != 0) {
            Hit found = ((HitGroup) hit).get(id, depth - 1);
            if (found != null)
                return found;
        }
    }
    return null;
}
Also used : URI(com.yahoo.net.URI)

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