Search in sources :

Example 6 with Relevance

use of com.yahoo.search.result.Relevance in project vespa by vespa-engine.

the class JsonRendererTestCase method testGroupingWithBucket.

@Test
public void testGroupingWithBucket() throws InterruptedException, ExecutionException, IOException {
    String expected = "{\n" + "    \"root\": {\n" + "        \"children\": [\n" + "            {\n" + "                \"children\": [\n" + "                    {\n" + "                        \"children\": [\n" + "                            {\n" + "                                \"fields\": {\n" + "                                    \"something()\": 7\n" + "                                },\n" + "                                \"limits\": {\n" + "                                    \"from\": \"1.0\",\n" + "                                    \"to\": \"2.0\"\n" + "                                },\n" + "                                \"id\": \"group:double_bucket:1.0:2.0\",\n" + "                                \"relevance\": 1.0\n" + "                            }\n" + "                        ],\n" + "                        \"id\": \"grouplist:customer\",\n" + "                        \"label\": \"customer\",\n" + "                        \"relevance\": 1.0\n" + "                    }\n" + "                ],\n" + "                \"continuation\": {\n" + "                    \"this\": \"AAAA\"\n" + "                },\n" + "                \"id\": \"group:root:0\",\n" + "                \"relevance\": 1.0\n" + "            }\n" + "        ],\n" + "        \"fields\": {\n" + "            \"totalCount\": 1\n" + "        },\n" + "        \"id\": \"toplevel\",\n" + "        \"relevance\": 1.0\n" + "    }\n" + "}\n";
    Result r = newEmptyResult();
    RootGroup rg = new RootGroup(0, new Continuation() {

        @Override
        public String toString() {
            return "AAAA";
        }
    });
    GroupList gl = new GroupList("customer");
    Group g = new Group(new DoubleBucketId(1.0, 2.0), new Relevance(1.0));
    g.setField("something()", Integer.valueOf(7));
    gl.add(g);
    rg.add(gl);
    r.hits().add(rg);
    r.setTotalHitCount(1L);
    String summary = render(r);
    assertEqualJson(expected, summary);
}
Also used : Relevance(com.yahoo.search.result.Relevance) Group(com.yahoo.search.grouping.result.Group) RootGroup(com.yahoo.search.grouping.result.RootGroup) HitGroup(com.yahoo.search.result.HitGroup) Continuation(com.yahoo.search.grouping.Continuation) GroupList(com.yahoo.search.grouping.result.GroupList) JSONString(com.yahoo.prelude.hitfield.JSONString) RootGroup(com.yahoo.search.grouping.result.RootGroup) DoubleBucketId(com.yahoo.search.grouping.result.DoubleBucketId) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 7 with Relevance

use of com.yahoo.search.result.Relevance in project vespa by vespa-engine.

the class QuerySnapshotSearcher method search.

public Result search(Query query, Execution execution) {
    Query q = query.clone();
    Result r = execution.search(query);
    Hit h = new Hit("meta:querysnapshot", new Relevance(Double.POSITIVE_INFINITY));
    h.setMeta(true);
    h.setField("query", q);
    r.hits().add(h);
    return r;
}
Also used : Relevance(com.yahoo.search.result.Relevance) Hit(com.yahoo.search.result.Hit) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result)

Example 8 with Relevance

use of com.yahoo.search.result.Relevance in project vespa by vespa-engine.

the class ResultBuilder method endElement.

@Override
public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
    switch(location.peekFirst()) {
        case HITGROUP:
            if ("group".equals(qName)) {
                hitGroups.removeFirst();
                location.removeFirst();
            }
            break;
        case HIT:
            if (fieldLevel > 0) {
                endElementInHitField(qName);
            } else if ("hit".equals(qName)) {
                // assert(hitKeys.size() == hitValues.size());
                // We try to get either uri or documentID and use that as id
                Object docId = extractDocumentID();
                Hit newHit = new Hit(docId.toString());
                if (hitRelevance != null)
                    newHit.setRelevance(new Relevance(DoubleParser.parse(hitRelevance)));
                if (hitSource != null)
                    newHit.setSource(hitSource);
                if (hitType != null) {
                    for (String type : hitType.split(" ")) {
                        newHit.types().add(type);
                    }
                }
                for (Map.Entry<String, Object> field : hitFields.entrySet()) {
                    newHit.setField(field.getKey(), field.getValue());
                }
                hitGroups.peekFirst().add(newHit);
                location.removeFirst();
            }
            break;
        case ERRORDETAILS:
            if (fieldLevel == 1 && ERROR.equals(qName)) {
                ErrorMessage error = new ErrorMessage(Integer.valueOf(currentErrorCode), currentError, fieldContent.toString());
                hitGroups.peekFirst().addError(error);
                currentError = null;
                currentErrorCode = null;
                fieldContent = null;
                tagStack = null;
                fieldLevel = 0;
            } else if (fieldLevel > 0) {
                endElementInField(qName, ERROR);
            } else if ("errordetails".equals(qName)) {
                location.removeFirst();
            }
            break;
        case ROOT:
            if (ERROR.equals(qName)) {
                ErrorMessage error = new ErrorMessage(Integer.valueOf(currentErrorCode), fieldContent.toString());
                hitGroups.peekFirst().addError(error);
                currentErrorCode = null;
                fieldContent = null;
            }
            break;
        default:
            break;
    }
    ++offset;
}
Also used : Relevance(com.yahoo.search.result.Relevance) Hit(com.yahoo.search.result.Hit) XMLString(com.yahoo.prelude.hitfield.XMLString) ErrorMessage(com.yahoo.search.result.ErrorMessage)

Example 9 with Relevance

use of com.yahoo.search.result.Relevance in project vespa by vespa-engine.

the class VdsStreamingSearcher method buildSummaryHit.

private FastHit buildSummaryHit(Query query, SearchResult.Hit hit) {
    FastHit fastHit = new FastHit();
    fastHit.setQuery(query);
    fastHit.setSource(getName());
    fastHit.setId(hit.getDocId());
    fastHit.setRelevance(new Relevance(hit.getRank()));
    fastHit.setFillable();
    return fastHit;
}
Also used : Relevance(com.yahoo.search.result.Relevance) FastHit(com.yahoo.prelude.fastsearch.FastHit)

Example 10 with Relevance

use of com.yahoo.search.result.Relevance in project vespa by vespa-engine.

the class JuniperSearcherTestCase method addResult.

private void addResult(Query query, String sdName, String content, DocumentSourceSearcher docsource) {
    Result r = new Result(query);
    FastHit hit = new FastHit();
    hit.setId("http://abc.html");
    hit.setRelevance(new Relevance(1));
    hit.setField(Hit.SDDOCNAME_FIELD, sdName);
    hit.setField("dynteaser", content);
    r.hits().add(hit);
    docsource.addResult(query, r);
}
Also used : Relevance(com.yahoo.search.result.Relevance) FastHit(com.yahoo.prelude.fastsearch.FastHit) Result(com.yahoo.search.Result)

Aggregations

Relevance (com.yahoo.search.result.Relevance)16 Hit (com.yahoo.search.result.Hit)10 Result (com.yahoo.search.Result)9 FastHit (com.yahoo.prelude.fastsearch.FastHit)8 Query (com.yahoo.search.Query)6 DocumentSourceSearcher (com.yahoo.prelude.searcher.DocumentSourceSearcher)4 QuotingSearcher (com.yahoo.prelude.searcher.QuotingSearcher)4 Searcher (com.yahoo.search.Searcher)4 Group (com.yahoo.search.grouping.result.Group)4 RootGroup (com.yahoo.search.grouping.result.RootGroup)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 JSONString (com.yahoo.prelude.hitfield.JSONString)3 GroupList (com.yahoo.search.grouping.result.GroupList)3 StringId (com.yahoo.search.grouping.result.StringId)3 Continuation (com.yahoo.search.grouping.Continuation)2 HitList (com.yahoo.search.grouping.result.HitList)2 HitGroup (com.yahoo.search.result.HitGroup)2 DocsumDefinitionSet (com.yahoo.prelude.fastsearch.DocsumDefinitionSet)1 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)1