1
|
/**
|
2
|
* Copyright (C) 2012 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.api.service.search;
|
10
|
|
11
|
import java.util.Collection;
|
12
|
import java.util.HashMap;
|
13
|
import java.util.Map;
|
14
|
|
15
|
import org.apache.lucene.document.Document;
|
16
|
import org.hibernate.search.engine.ProjectionConstants;
|
17
|
|
18
|
/**
|
19
|
* TODO class description
|
20
|
*
|
21
|
* @author Andreas Kohlbecker
|
22
|
\* @since Jan 6, 2012
|
23
|
*
|
24
|
*/
|
25
|
public class DocumentSearchResult {
|
26
|
|
27
|
private float score = 0;
|
28
|
|
29
|
private float maxScore = 0;
|
30
|
|
31
|
|
32
|
public DocumentSearchResult() {
|
33
|
}
|
34
|
|
35
|
/**
|
36
|
* key will be a combination of DocumentBuilder.CLASS_FIELDNAME and id field: ID_FIELD
|
37
|
*/
|
38
|
private final Map<String, Document> docs = new HashMap<String, Document>();
|
39
|
private Map<String,String[]> fieldHighlightMap;
|
40
|
|
41
|
|
42
|
public double getScore() {
|
43
|
return score;
|
44
|
}
|
45
|
|
46
|
|
47
|
public void setScore(float score) {
|
48
|
this.score = score;
|
49
|
}
|
50
|
|
51
|
|
52
|
public Map<String,String[]> getFieldHighlightMap() {
|
53
|
return fieldHighlightMap;
|
54
|
}
|
55
|
|
56
|
public void setFieldHighlightMap(Map<String,String[]> fieldHighlightMap) {
|
57
|
this.fieldHighlightMap = fieldHighlightMap;
|
58
|
}
|
59
|
|
60
|
|
61
|
|
62
|
public float getMaxScore() {
|
63
|
return maxScore;
|
64
|
}
|
65
|
|
66
|
|
67
|
public void setMaxScore(float maxScore) {
|
68
|
this.maxScore = maxScore;
|
69
|
}
|
70
|
|
71
|
|
72
|
public Collection<Document> getDocs() {
|
73
|
return docs.values();
|
74
|
}
|
75
|
|
76
|
|
77
|
public void addDoc(Document doc) {
|
78
|
String key = doc.getValues(ProjectionConstants.OBJECT_CLASS)[0] + "." + doc.getValues(LuceneSearch.ID_FIELD)[0];
|
79
|
this.docs.put(key, doc);
|
80
|
}
|
81
|
|
82
|
|
83
|
|
84
|
}
|