public class XmlIndexer extends Object
| Constructor and Description |
|---|
XmlIndexer()
Make a new instance with default options
|
XmlIndexer(IndexConfiguration config)
Make a new instance with the given configuration.
|
XmlIndexer(IndexConfiguration indexConfig,
Compiler compiler)
Make a new instance with the given options and Compiler.
|
XmlIndexer(long options)
Make a new instance with the given options.
|
| Modifier and Type | Method and Description |
|---|---|
org.apache.lucene.document.Document |
createLuceneDocument() |
net.sf.saxon.s9api.XdmValue |
evaluateXPath(String xpath)
this is primarily for internal use
|
IndexConfiguration |
getConfiguration() |
byte[] |
getDocumentBytes() |
String |
getDocumentText() |
XmlPathMapper |
getPathMapper()
Primarily for internal use.
|
SaxonDocBuilder |
getSaxonDocBuilder()
Primarily for internal use.
|
String |
getURI() |
net.sf.saxon.s9api.XdmNode |
getXdmNode() |
net.sf.saxon.s9api.XPathCompiler |
getXPathCompiler()
this is primarily for internal use
|
void |
index(InputStream xml,
String inputUri)
Index the document read from the stream, caching field values to be written
to the Lucene index.
|
void |
index(net.sf.saxon.om.NodeInfo doc,
String inputUri)
Index the document read from the String, caching field values to be
written to the Lucene index.
|
void |
index(Reader xml,
String inputUri)
Index the document read from the Reader, caching field values to be written
to the Lucene index.
|
void |
indexDocument(org.apache.lucene.index.IndexWriter indexWriter,
String docUri,
InputStream xmlStream)
Index and write a document to the Lucene index.
|
void |
indexDocument(org.apache.lucene.index.IndexWriter indexWriter,
String path,
net.sf.saxon.om.NodeInfo node)
Index and write a document to the Lucene index.
|
void |
indexDocument(org.apache.lucene.index.IndexWriter indexWriter,
String docUri,
String xml)
Index and write a document to the Lucene index.
|
protected void |
init()
initialize the indexer; an extension of the constructors.
|
org.apache.lucene.index.IndexWriter |
newIndexWriter(org.apache.lucene.store.Directory dir)
Constructs a new Lucene IndexWriter for the given index directory
supplied with the proper analyzers for each field.
|
void |
reset()
Clear out internal storage cached by #index when indexing a document
|
void |
storeDocument(org.apache.lucene.index.IndexWriter indexWriter,
String docUri,
byte[] bytes)
Fully read the stream and store it as a document without attempting to parse or index it.
|
void |
storeDocument(org.apache.lucene.index.IndexWriter indexWriter,
String docUri,
InputStream input)
Fully read the stream and store it as a document without attempting to parse or index it.
|
public XmlIndexer()
public XmlIndexer(IndexConfiguration config)
config - the index configuration to usepublic XmlIndexer(long options)
options - the index configuration options to usepublic XmlIndexer(IndexConfiguration indexConfig, Compiler compiler)
indexConfig - the index configuration options to usecompiler - the indexer will make XPath that is compatible with this compilerprotected void init()
public org.apache.lucene.index.IndexWriter newIndexWriter(org.apache.lucene.store.Directory dir)
throws IOException
dir - the directory where the index is storedIOException - if there is a problem with the indexpublic net.sf.saxon.s9api.XPathCompiler getXPathCompiler()
public net.sf.saxon.s9api.XdmValue evaluateXPath(String xpath) throws net.sf.saxon.s9api.SaxonApiException
xpath - an xpath expression to evaluatenet.sf.saxon.s9api.SaxonApiException - if there is an error during compilation or evaluationpublic void index(InputStream xml, String inputUri) throws XMLStreamException
xml - the document, as a byte-based InputStreaminputUri - the uri to assign to the documentXMLStreamExceptionpublic void index(Reader xml, String inputUri) throws XMLStreamException
xml - the document, as a character-based ReaderinputUri - the uri to assign to the documentXMLStreamExceptionpublic void index(net.sf.saxon.om.NodeInfo doc,
String inputUri)
throws XMLStreamException
doc - the document (or element) as a Saxon NodeInfoinputUri - the uri to assign to the documentXMLStreamExceptionpublic void reset()
public String getURI()
public net.sf.saxon.s9api.XdmNode getXdmNode()
public String getDocumentText()
public byte[] getDocumentBytes()
storeDocument(IndexWriter, String, InputStream)
was called.public void indexDocument(org.apache.lucene.index.IndexWriter indexWriter,
String docUri,
String xml)
throws XMLStreamException,
IOException
indexWriter - the Lucene IndexWriter for the index to write todocUri - the uri to assign to the document; any scheme will
be stripped: only the path is stored in the indexxml - the text of an xml document to indexXMLStreamException - if there is an error parsing the documentIOException - if there is an error writing to the indexpublic void indexDocument(org.apache.lucene.index.IndexWriter indexWriter,
String docUri,
InputStream xmlStream)
throws XMLStreamException,
IOException
indexWriter - the Lucene IndexWriter for the index to write todocUri - the uri to assign to the document; any scheme will
be stripped: only the path is stored in the indexxmlStream - a stream from which the text of an xml document is to be readXMLStreamException - if there is an error parsing the documentIOException - if there is an error writing to the indexpublic void storeDocument(org.apache.lucene.index.IndexWriter indexWriter,
String docUri,
InputStream input)
throws IOException
indexWriter - the Lucene IndexWriter for the index to write todocUri - the uri to assign to the document; any scheme will be stripped: only the path is stored in the indexinput - the stream to read the document fromIOException - if there is an error writing to the indexpublic void storeDocument(org.apache.lucene.index.IndexWriter indexWriter,
String docUri,
byte[] bytes)
throws IOException
indexWriter - the Lucene IndexWriter for the index to write todocUri - the uri to assign to the document; any scheme will be stripped: only the path is stored in the indexbytes - the document bytes to storeIOException - if there is an error writing to the indexpublic void indexDocument(org.apache.lucene.index.IndexWriter indexWriter,
String path,
net.sf.saxon.om.NodeInfo node)
throws XMLStreamException,
IOException
indexWriter - the Lucene IndexWriter for the index to write topath - the uri to assign to the documentnode - an xml document to index, as a Saxon NodeInfoXMLStreamException - if there is an error parsing the documentIOException - if there is an error writing to the indexpublic org.apache.lucene.document.Document createLuceneDocument()
Document created
from the field values stored in this indexer. The document is ready
to be inserted into Lucene via IndexWriter.addDocument(java.lang.Iterable<? extends org.apache.lucene.index.IndexableField>).public SaxonDocBuilder getSaxonDocBuilder()
SaxonDocBuilder used by the indexer to construct XdmNodes.public XmlPathMapper getPathMapper()
XmlPathMapper used by the indexer to gather node paths.public IndexConfiguration getConfiguration()
Copyright © 2013. All Rights Reserved.