merging delete functionality into trunk
[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.ProjectionConstants;
18
19 import eu.etaxonomy.cdm.model.common.CdmBase;
20
21 /**
22 * TODO class description
23 *
24 * @author Andreas Kohlbecker
25 * @date Jan 6, 2012
26 *
27 */
28 public class DocumentSearchResult {
29
30 private float score = 0;
31
32 private float maxScore = 0;
33
34
35 public DocumentSearchResult() {
36 }
37
38 /**
39 * key will be a combination of DocumentBuilder.CLASS_FIELDNAME and id field: ID_FIELD
40 */
41 private Map<String, Document> docs = new HashMap<String, Document>();
42 private Map<String,String[]> fieldHighlightMap;
43
44
45 public double getScore() {
46 return score;
47 }
48
49
50 public void setScore(float score) {
51 this.score = score;
52 }
53
54
55 public Map<String,String[]> getFieldHighlightMap() {
56 return fieldHighlightMap;
57 }
58
59 public void setFieldHighlightMap(Map<String,String[]> fieldHighlightMap) {
60 this.fieldHighlightMap = fieldHighlightMap;
61 }
62
63
64
65 public float getMaxScore() {
66 return maxScore;
67 }
68
69
70 public void setMaxScore(float maxScore) {
71 this.maxScore = maxScore;
72 }
73
74
75 public Collection<Document> getDocs() {
76 return docs.values();
77 }
78
79
80 public void addDoc(Document doc) {
81 String key = doc.getValues(ProjectionConstants.OBJECT_CLASS)[0] + "." + doc.getValues(LuceneSearch.ID_FIELD)[0];
82 this.docs.put(key, doc);
83 }
84
85
86
87 }