*/
package eu.etaxonomy.cdm.api.service.search;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
import org.apache.lucene.document.Document;
+import org.hibernate.search.engine.DocumentBuilder;
import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
-import eu.etaxonomy.cdm.model.common.VersionableEntity;
-import eu.etaxonomy.cdm.persistence.dao.common.ICdmEntityDao;
/**
* TODO class description
private float maxScore = 0;
- private Document doc;
+ private final String ID_FIELD = "id";
+
+ /**
+ * key will be a combination of DocumentBuilder.CLASS_FIELDNAME and id field: ID_FIELD
+ */
+ private Map<String, Document> docs = new HashMap<String, Document>();
+
private T entity;
this.score = score;
}
+ @Deprecated
public Document getDoc() {
- return doc;
+ return docs.values().iterator().next();
}
-
+ @Deprecated
public void setDoc(Document doc) {
- this.doc = doc;
+ addDoc(doc);
}
public T getEntity() {
* @param entity
*/
public SearchResult(Document doc) {
- this.doc = doc;
+ addDoc(doc);
+ }
+
+ public SearchResult() {
}
}
+ public Collection<Document> getDocs() {
+ return docs.values();
+ }
+
+
+ public void addDoc(Document doc) {
+ String key = doc.getValues(DocumentBuilder.CLASS_FIELDNAME)[0] + "." + doc.getValues(ID_FIELD)[0];
+ this.docs.put(key, doc);
+ }
+
+