Package org.dlese.dpc.index.reader
Class DocumentMap
java.lang.Object
org.dlese.dpc.index.reader.DocumentMap
- All Implemented Interfaces:
Map
A
Map for accessing the data stored in a Lucene Document as field/value pairs. All data is loaded from the index into the Map
when any Map accessor method is called (e.g. eager loading), making data available even if the underlying
index later changes, but also making access to very large Documents inefficient. Each stored field in the
Document corresponds to a key in the Map. For example
documentMap.get("title") gets the text that was indexed and stored under the field name "title" for the
Document. Supports read operations only. A DocumentMap is available from search results by calling ResultDoc.getDocMap(). Example that uses JSTL inside a JSP page (assumes result is an instance of ResultDoc):
The title is: ${result.docMap["title"]}.
- Author:
- John Weatherley
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor for the DocumentMap object.DocumentMap(org.apache.lucene.document.Document doc) Constructor for the DocumentMap object. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Method not supported.booleancontainsKey(Object fieldName) Determines whether a given field exists in the LuceneDocument.booleancontainsValue(Object value) Determines whether the given field value is present in the LuceneDocument.entrySet()Gets the Set of field/value entries for the LuceneDocument.Gets the text content of the given Lucene field as a String or null if the given field is not available or was not stored in the index.booleanisEmpty()Determines whether there are no fields in thisDocument.keySet()Gets the field names in the LuceneDocument.Method not supported.voidMethod not supported.Method not supported.intsize()Gets the number of fields in theDocument.values()Gets all field values that are present in the LuceneDocument.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
DocumentMap
public DocumentMap(org.apache.lucene.document.Document doc) Constructor for the DocumentMap object.- Parameters:
doc- The Lucene Document that is exposed by this Map.
-
DocumentMap
public DocumentMap()Constructor for the DocumentMap object.
-
-
Method Details
-
get
Gets the text content of the given Lucene field as a String or null if the given field is not available or was not stored in the index. Text contains all stored values for the given field. -
keySet
Gets the field names in the LuceneDocument. -
entrySet
Gets the Set of field/value entries for the LuceneDocument. EachMap.EntryObject in the Set contains the field name (key) and corresponding field value. The field value will be an empty String if the given field was not set to be stored in the index. -
containsKey
Determines whether a given field exists in the LuceneDocument.- Specified by:
containsKeyin interfaceMap- Parameters:
fieldName- A field name- Returns:
- True if the field exists in the Lucene
Document
-
values
Gets all field values that are present in the LuceneDocument. -
containsValue
Determines whether the given field value is present in the LuceneDocument.- Specified by:
containsValuein interfaceMap- Parameters:
value- A field value- Returns:
- True if the field value is present in this
Document
-
isEmpty
public boolean isEmpty()Determines whether there are no fields in thisDocument. -
size
public int size()Gets the number of fields in theDocument. -
putAll
Method not supported. -
put
Method not supported. -
remove
Method not supported. -
clear
public void clear()Method not supported.
-