|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectprefuse.data.search.LuceneSearcher
public class LuceneSearcher
Adapter class for interfacing with the Lucene search engine. By default, instances of this class use an in-memory search index for English language text, for use within a single application session. The class can, however, be parameterized for any number of other configurations, including accessing persistent search indices.
| Field Summary | |
|---|---|
static java.lang.String |
FIELD
Default Document field used to index text. |
static java.lang.String |
ID
Document field used to store the document ID number. |
| Constructor Summary | |
|---|---|
LuceneSearcher()
Create a new LuceneSearcher using an in-memory search index. |
|
LuceneSearcher(org.apache.lucene.store.Directory dir)
Create a new LuceneSearcher using the specified search index location. |
|
LuceneSearcher(org.apache.lucene.store.Directory dir,
java.lang.String[] fields,
boolean readOnly)
Create a new LuceneSearcher using a specified search index location, a particular Document fields to index, and given read/write status. |
|
LuceneSearcher(org.apache.lucene.store.Directory dir,
java.lang.String field,
boolean readOnly)
Create a new LuceneSearcher using a specified search index location, a particular Document field to index, and given read/write status. |
|
| Method Summary | |
|---|---|
void |
addDocument(org.apache.lucene.document.Document d)
Add a document to the Lucene search index. |
org.apache.lucene.analysis.Analyzer |
getAnalyzer()
Returns the Analyzer used to process text. |
java.lang.String[] |
getFields()
Returns the indexed Document fields. |
org.apache.lucene.index.IndexReader |
getIndexReader()
Returns the Lucene IndexReader. |
org.apache.lucene.search.Searcher |
getIndexSearcher()
Returns the Lucene IndexSearcher. |
boolean |
isReadOnly()
Indicates if ths LuceneSearcher is read-only. |
int |
numHits(java.lang.String query)
Return the result count for the given search query. |
org.apache.lucene.search.Hits |
search(java.lang.String query)
Searches the Lucene index using the given query String, returns an object which provides access to the search results. |
void |
setAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
Sets the Analyzer used to process text. |
void |
setFields(java.lang.String[] fields)
Sets the indexed Document fields. |
boolean |
setReadMode(boolean mode)
Sets if this LuceneSearcher is in read mode or write mode. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String FIELD
public static final java.lang.String ID
| Constructor Detail |
|---|
public LuceneSearcher()
public LuceneSearcher(org.apache.lucene.store.Directory dir)
dir - the Lucene Directory indicating the search index to use.
public LuceneSearcher(org.apache.lucene.store.Directory dir,
java.lang.String field,
boolean readOnly)
dir - the Lucene Directory indicating the search index to use.field - the Lucene Document field that should be indexed.readOnly - if this index is read-only or is writable.
public LuceneSearcher(org.apache.lucene.store.Directory dir,
java.lang.String[] fields,
boolean readOnly)
dir - the Lucene Directory indicating the search index to use.fields - the Lucene Document fields that should be indexed.readOnly - if this index is read-only or is writable.| Method Detail |
|---|
public boolean setReadMode(boolean mode)
mode - true for read mode, false for write mode.
public org.apache.lucene.search.Hits search(java.lang.String query)
throws org.apache.lucene.queryParser.ParseException,
java.io.IOException
query - the search query
org.apache.lucene.queryParser.ParseException - if the query is not parsed successfully
java.io.IOException - if an input/ouput error occurs
java.lang.IllegalStateException - if the searcher is in write mode
public int numHits(java.lang.String query)
throws org.apache.lucene.queryParser.ParseException,
java.io.IOException
query - the search query
org.apache.lucene.queryParser.ParseException - if the query is not parsed successfully
java.io.IOException - if an input/ouput error occurs
java.lang.IllegalStateException - if the searcher is in write modepublic void addDocument(org.apache.lucene.document.Document d)
d - the Document to add
java.lang.IllegalStateException - if the searcher is not in write modepublic org.apache.lucene.analysis.Analyzer getAnalyzer()
public void setAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
analyzer - the analyzer to setpublic java.lang.String[] getFields()
public void setFields(java.lang.String[] fields)
public org.apache.lucene.index.IndexReader getIndexReader()
public org.apache.lucene.search.Searcher getIndexSearcher()
public boolean isReadOnly()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||