Package org.dlese.dpc.index.reader
Class DocReader
java.lang.Object
org.dlese.dpc.index.reader.DocReader
- Direct Known Subclasses:
FileIndexingServiceDocReader,HarvestLogReader,SimpleDocReader,WebLogReader
An abstract bean for accessing the data stored in the Lucene
Documents
that are returned from a search. All concrete DocReader classes must implement a default no-argument
constructor so that they may be created automatically by the factory ResultDoc.getDocReader(). In addition, the index writer corresponding to the concrete
reader must implement the DocWriter.getReaderClass() method.- Author:
- John Weatherley
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ResultDocConfigThe index that was searched over.protected org.apache.lucene.document.DocumentThe Lucene Document that is being read.protected ResultDocprotected floatThe Lucene score assigned to the Document, or -1 if none available. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voiddoInit(org.apache.lucene.document.Document myDoc, ResultDoc resultDoc, float myScore, ResultDocConfig myConf) Called byResultDocat search time to initialize a new instance of a DocReader.getAttribute(String key) Gets an attribute that has been previously set usingSimpleLuceneIndex.setAttribute(String,Object).Gets aDocumentMapof all field/values contained in the LuceneDocument.org.apache.lucene.document.DocumentGets the LuceneDocumentassociated with this DocReader.getIndex()Gets the index that was searched over to produce the resulting hit.Gets aLazyDocumentMapof all field/values contained in the LuceneDocument.getQuery()Gets the query that was used in the search.abstract StringGets a String describing the reader type.Gets the RepositoryManager associated with this DocReader or null if not available.getScore()Gets the Lucene score for theDocument, or -1 if none available.abstract voidinit()An init method that may be used by concrete classes to initialize variables and resources as needed.protected voidsetDoc(org.apache.lucene.document.Document myDoc) Sets the Lucene Document that is being read by this DocReader.
-
Field Details
-
doc
protected org.apache.lucene.document.Document docThe Lucene Document that is being read. -
score
protected float scoreThe Lucene score assigned to the Document, or -1 if none available. -
conf
The index that was searched over. -
resultDoc
-
-
Constructor Details
-
DocReader
protected DocReader(org.apache.lucene.document.Document myDoc) Constructor that may be used programatically to wrap a reader around a LuceneDocumentthat was created by aDocWriter.- Parameters:
myDoc- Gets the Lucene Document that is being read by this DocReader.- See Also:
-
DocReader
protected DocReader()Constructor that initializes an empty DocReader.
-
-
Method Details
-
getReaderType
Gets a String describing the reader type. This may be used in (Struts) beans to determine which type of reader is available for a given search result and thus what data is available for display in the UI. The reader type implies which getter methods are available.- Returns:
- The readerType value.
-
init
public abstract void init()An init method that may be used by concrete classes to initialize variables and resources as needed. -
doInit
public final void doInit(org.apache.lucene.document.Document myDoc, ResultDoc resultDoc, float myScore, ResultDocConfig myConf) Called byResultDocat search time to initialize a new instance of a DocReader.- Parameters:
myDoc- The Lucene DocumentmyScore- The Lucene score asigned to this hitmyConf- The config available to the doc reader
-
getDocMap
Gets aDocumentMapof all field/values contained in the LuceneDocument. The text values in each field is stored in the Map as Strings. For example getDocMap.get("title") returns the text that was indexed and stored under the field name "title" for this Document.Example that uses JSTL inside a JSP page (assumes result is an instance of ResultDoc):
The title is: ${result.docMap["title"]}- Returns:
- A Map of all field/values contained in this Document, or null
- See Also:
-
getLazyDocMap
Gets aLazyDocumentMapof all field/values contained in the LuceneDocument. The text values in each field is stored in the Map as Strings. For example getDocMap.get("title") returns the text that was indexed and stored under the field name "title" for this Document.Example that uses JSTL inside a JSP page (assumes result is an instance of ResultDoc):
The title is: ${result.docMap["title"]}- Returns:
- A Map of all field/values contained in this Document, or null
- See Also:
-
setDoc
protected void setDoc(org.apache.lucene.document.Document myDoc) Sets the Lucene Document that is being read by this DocReader.- Parameters:
myDoc- The new doc value
-
getScore
Gets the Lucene score for theDocument, or -1 if none available.- Returns:
- The score or -1 if not available.
-
getDocument
public org.apache.lucene.document.Document getDocument()Gets the LuceneDocumentassociated with this DocReader.- Returns:
- A Lucene
Document.
-
getIndex
Gets the index that was searched over to produce the resulting hit.- Returns:
- The index.
-
getAttribute
Gets an attribute that has been previously set usingSimpleLuceneIndex.setAttribute(String,Object).- Parameters:
key- The key for the attribute- Returns:
- The attruibute, or null if none exists under the given key
- See Also:
-
getRepositoryManager
Gets the RepositoryManager associated with this DocReader or null if not available. Assumes the RepositoryManager has been set as attribute 'repositoryManager' in the SimpleLuceneIndex that was searched.- Returns:
- The repositoryManager value
-
getQuery
Gets the query that was used in the search.- Returns:
- The query value
-