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