blob: 55f3163c55ae7dfa0c80747a1864ef1d56a31e8a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.storage.searcher;
import com.yahoo.document.Document;
import com.yahoo.document.Field;
import com.yahoo.document.datatypes.FieldValue;
import com.yahoo.search.result.Hit;
import java.util.Iterator;
import java.util.Map;
public class DocumentHit extends Hit {
private Document document;
private int index;
public DocumentHit(Document document, int index) {
super(document.getId().toString());
this.document = document;
this.index = index;
}
public void populateHitFields() {
// Create hit fields for all document fields
Iterator<Map.Entry<Field, FieldValue>> fieldIter = document.iterator();
while (fieldIter.hasNext()) {
Map.Entry<Field, FieldValue> field = fieldIter.next();
setField(field.getKey().getName(), field.getValue());
}
// Assign an explicit document id field
setField("documentid", document.getId().toString());
}
public Document getDocument() {
return document;
}
public int getIndex() {
return index;
}
}
|