public class LazyDocumentMap
extends java.lang.Object
implements java.util.Map
Map
for accessing the data stored in a Lucene Document
as field/value pairs. The data is loaded from the index only when
requested via the Map accessor methods (e.g. lazy loading), making access to very large Documents possible
in an efficient manner. 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 LazyDocumentMap 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"]}.
Document
,
ResultDoc
,
DocumentMap
Modifier and Type | Class and Description |
---|---|
class |
LazyDocumentMap.FieldMapEntry
A Map entry containing lucene fieldName/fieldValues
|
class |
LazyDocumentMap.FieldNameList
A List for field names in a Lucene Document.
|
class |
LazyDocumentMap.FieldNameSet
A Set for field names in a Lucene Document.
|
class |
LazyDocumentMap.FieldValuesList
A List for field values in a Lucene Document.
|
class |
LazyDocumentMap.FieldValuesSet
A Set for field values in a Lucene Document.
|
Constructor and Description |
---|
LazyDocumentMap()
Constructor for the LazyDocumentMap object.
|
LazyDocumentMap(org.apache.lucene.document.Document doc)
Constructor for the LazyDocumentMap object.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Method not supported.
|
boolean |
containsKey(java.lang.Object fieldName)
Determines whether a given field exists in the Lucene
Document . |
boolean |
containsValue(java.lang.Object value)
Determines whether the given field value is present in the Lucene
Document . |
java.util.Set |
entrySet()
Gets the Set of field/value entries for the Lucene
Document . |
java.lang.String |
get(java.lang.Object fieldName)
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.
|
LazyDocumentMap.FieldNameList |
getFieldNames()
Gets the names of all fields in the document as Strings.
|
LazyDocumentMap.FieldValuesList |
getFieldValues()
Gets the values for all fields in the document as Map.Entry Objects.
|
java.lang.String |
getFirstTextValue(java.lang.String fieldName)
Returns the string value of the field with the given name if any exist in this document, or null.
|
boolean |
isEmpty()
Determines whether there are no fields in this
Document . |
java.util.Set |
keySet()
Gets the field names in the Lucene
Document . |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Method not supported.
|
void |
putAll(java.util.Map t)
Method not supported.
|
java.lang.Object |
remove(java.lang.Object key)
Method not supported.
|
int |
size()
Gets the number of fields in the
Document . |
java.util.Collection |
values()
Gets all field values that are present in the Lucene
Document . |
public LazyDocumentMap(org.apache.lucene.document.Document doc)
doc
- The Lucene Document that is exposed by this Map.public LazyDocumentMap()
public LazyDocumentMap.FieldNameList getFieldNames()
keySet()
public LazyDocumentMap.FieldValuesList getFieldValues()
public java.lang.String getFirstTextValue(java.lang.String fieldName)
fieldName
- Name of the fieldpublic java.lang.String get(java.lang.Object fieldName)
get
in interface java.util.Map
fieldName
- A Lucene Document
field namepublic java.util.Set keySet()
Document
. This is similar to
#getFieldNames but it also loads all field/values into the Map and is therfore more expensive than
#getFieldNames, especially for large Documents.keySet
in interface java.util.Map
getFieldNames()
public java.util.Set entrySet()
Document
. Each
Map.Entry
Object 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.entrySet
in interface java.util.Map
Map.Entry
public boolean containsKey(java.lang.Object fieldName)
Document
.containsKey
in interface java.util.Map
fieldName
- A field nameDocument
public java.util.Collection values()
Document
.values
in interface java.util.Map
public boolean containsValue(java.lang.Object value)
Document
.containsValue
in interface java.util.Map
value
- A field valueDocument
public boolean isEmpty()
Document
.isEmpty
in interface java.util.Map
public int size()
Document
.size
in interface java.util.Map
Document
public void putAll(java.util.Map t)
putAll
in interface java.util.Map
t
- Not supported.public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
key
- Not supported.value
- Not supported.public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
key
- Not supported.public void clear()
clear
in interface java.util.Map