|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.transaxtions.search.rankingalgorithm.RankingQuery
public class RankingQuery
The RankingAlgorithm implementation. Uses Lucene to get documents from the index but scores and ranks using the RankingAlgorithm. RankingAlgorithm can be used in two modes, Document mode (default) and Product mode. The scoring changes with the mode. In Document mode, documents are matched for relevancy while in Product mode, documents are matched for term occurence. Document mode is useful for matching text, html, rich text pdf/word, books, faq, forums discussions, etc. Product mode useful for small text as in Retail Product matches, etc. Product mode also has scan speed to fast/medium/full scan. Full scan is the most accurate but also a little slow. Needs the Lucene indexPath or IndexSearcher or IndexReader at instantiation or at search time. Uses the IndexReader to read the documents from the Index.
Example:
RankingQuery rq = new RankingQuery();
IndexSearcher is = new IndexSearcher(index);
StandardAnalyzer analyzer = new StandardAnalyzer();
QueryParser parser = new QueryParser(field, analyzer);
Query query = parser.parse(searchterms);
RankingHits rh = rq.search(query, is); //is = Lucene IndexSearcher object
System.out.println("num hits=" + rh.getNumHits() + "--no docs=" + is.maxDoc());
for (int i=0; i<rh.getNumHits() && i<10; i++) {
System.out.println("i=" + i + "--" + rh.score(i) + "--docid=" + rh.docid(i) + "--doc=" + rh.doc(i).get(title) );
}
RankingQuery,
RankingHits,
RankingScore| Field Summary | |
|---|---|
static int |
ALGORITHM_COMPLEX
Deprecated. |
static int |
ALGORITHM_SIMPLE
Deprecated. |
static int |
AND
Deprecated. |
static int |
AND_OR
Deprecated. |
static int |
DOCUMENT_MODE
Deprecated. |
static int |
FOLD_FACTOR
Deprecated. |
static int |
NUM_THREADS
Deprecated. |
static int |
OR
Deprecated. |
static int |
PRODUCT_MODE
Deprecated. |
static int |
SCAN_FAST
Deprecated. |
static int |
SCAN_FULL
Deprecated. |
static int |
SCAN_MEDIUM
Deprecated. |
| Constructor Summary | |
|---|---|
RankingQuery()
Deprecated. |
|
RankingQuery(org.apache.lucene.index.IndexReader reader)
Deprecated. Constructor to create a RankingQuery object. |
|
RankingQuery(org.apache.lucene.search.IndexSearcher is)
Deprecated. Constructor to create a RankingQuery object. |
|
RankingQuery(java.lang.String indexPath)
Deprecated. Constructor to create a RankingQuery object. |
|
| Method Summary | |
|---|---|
void |
addToLowerBoostSet(java.lang.String keywords)
Deprecated. Experimental, can change |
void |
close()
Deprecated. Closes the IndexReader objects opened. |
org.apache.lucene.document.Document |
doc(int docid)
Deprecated. Similar to IndexSearcher doc(id), returns a Lucene Document object |
int |
getAndOr()
Deprecated. |
int |
getMode()
Deprecated. |
int |
getScan()
Deprecated. |
RankingHits |
search(org.apache.lucene.search.Query query)
Deprecated. Similar to Lucene search. |
RankingHits |
search(org.apache.lucene.search.Query query,
org.apache.lucene.search.Filter filter,
org.apache.lucene.index.IndexReader ir,
org.apache.lucene.search.Collector collector)
Deprecated. Similar to Lucene search. |
RankingHits |
search(org.apache.lucene.search.Query query,
org.apache.lucene.index.IndexReader r)
Deprecated. Similar to Lucene search. |
RankingHits |
search(org.apache.lucene.search.Query query,
org.apache.lucene.search.IndexSearcher is)
Deprecated. Similar to Lucene search. |
RankingHits |
search(java.lang.String field,
java.lang.String searchTerms)
Deprecated. Similar to Lucene search. |
int |
search(org.apache.lucene.search.Weight weight,
org.apache.lucene.search.Filter filter,
org.apache.lucene.index.IndexReader[] ir,
org.apache.lucene.search.Collector collector,
int[] docstart)
Deprecated. |
RankingHits |
search(org.apache.lucene.search.Weight weight,
org.apache.lucene.search.Filter filter,
org.apache.lucene.index.IndexReader ir,
org.apache.lucene.search.Collector collector)
Deprecated. |
void |
setAndOr(int type)
Deprecated. Set And Or or AndOr combinations to get at the results. |
void |
setMode(int type)
Deprecated. Set mode, Document or Product mode. |
void |
setScan(boolean fast)
Deprecated. Used in Product mode. |
void |
setScan(int full)
Deprecated. Used in Product mode. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int ALGORITHM_COMPLEX
public static final int ALGORITHM_SIMPLE
public static final int PRODUCT_MODE
public static final int DOCUMENT_MODE
public static final int SCAN_FAST
public static final int SCAN_MEDIUM
public static final int SCAN_FULL
public static final int AND_OR
public static final int AND
public static final int OR
public static final int NUM_THREADS
public static final int FOLD_FACTOR
| Constructor Detail |
|---|
public RankingQuery(org.apache.lucene.index.IndexReader reader)
reader - Lucene InndexReader object.public RankingQuery(org.apache.lucene.search.IndexSearcher is)
is - Lucene IndexSearcher object.
public RankingQuery(java.lang.String indexPath)
throws java.lang.Throwable
indexPath - to a Lucene index.
java.lang.Throwablepublic RankingQuery()
| Method Detail |
|---|
public void setScan(boolean fast)
fast - true for FAST.public void setScan(int full)
full - Valid values are RankingQuery.FAST, RankingQuery.MEDIUM, RankingQuery.FULLpublic int getScan()
public void setMode(int type)
type - Valid values are RankingQuery.DOCUMENT_MODE or RankingQuery.PRODUCT_MODEpublic int getMode()
public void setAndOr(int type)
type - Valid values are RankingQuery.AND or RankingQuery.AND_OR or RankingQuery.OR. One can also
set this to any value between 0 and 100 as needed.public int getAndOr()
public void close()
throws java.lang.Throwable
java.lang.ThrowableRankingQuery(String),
SimpleExample
public org.apache.lucene.document.Document doc(int docid)
throws java.lang.Throwable
docid - Lucene document id
java.lang.Throwable
public RankingHits search(org.apache.lucene.search.Query query)
throws java.lang.Throwable
query - A Lucene query object
java.lang.ThrowableRankingHits
public RankingHits search(java.lang.String field,
java.lang.String searchTerms)
throws java.lang.Throwable
Example:
RankingQuery rq = new RankingQuery("/lucene/index/perl");
RankingHits rh = rq.search("search terms", "text");
System.out.println("num hits=" + rh.getNumHits() + "--no docs=" + is.maxDoc());
for (int i=0; i<rh.getNumHits() && i<10; i++) {
System.out.println("i=" + i + "--" + rh.score(i) + "--docid=" + rh.docid(i) + "--doc=" + rh.doc(i).get(title) );
}
field - to searchsearchTerms - search terms
java.lang.ThrowableRankingHits
public RankingHits search(org.apache.lucene.search.Query query,
org.apache.lucene.search.IndexSearcher is)
throws java.lang.Throwable
Example:
RankingQuery rq = new RankingQuery();
RankingHits rh = rq.search(query, is); //is = Lucene IndexSearcher object
System.out.println("num hits=" + rh.getNumHits() + "--no docs=" + is.maxDoc());
for (int i=0; i<rh.getNumHits() && i<10; i++) {
System.out.println("i=" + i + "--" + rh.score(i) + "--docid=" + rh.docid(i) + "--doc=" + rh.doc(i).get(title) );
}
query - Lucene query objectis - Lucene IndexSearcher object
java.lang.ThrowableRankingHits
public RankingHits search(org.apache.lucene.search.Query query,
org.apache.lucene.index.IndexReader r)
throws java.lang.Throwable
Example:
RankingQuery rq = new RankingQuery();
RankingHits rh = rq.search(query, is); //is = Lucene IndexSearcher object
System.out.println("num hits=" + rh.getNumHits() + "--no docs=" + is.maxDoc());
for (int i=0; i<rh.getNumHits() && i<10; i++) {
System.out.println("i=" + i + "--" + rh.score(i) + "--docid=" + rh.docid(i) + "--doc=" + rh.doc(i).get(title) );
}
query - Lucene query objectr - Lucene IndexSearcher object
java.lang.ThrowableRankingHits
public RankingHits search(org.apache.lucene.search.Query query,
org.apache.lucene.search.Filter filter,
org.apache.lucene.index.IndexReader ir,
org.apache.lucene.search.Collector collector)
throws java.lang.Throwable
Example:
RankingQuery rq = new RankingQuery();
RankingHits rh = rq.search(query, filter, ir, collector); //is = Lucene IndexSearcher object
System.out.println("num hits=" + rh.getNumHits() + "--no docs=" + is.maxDoc());
for (int i=0; i<rh.getNumHits() && i<10; i++) {
System.out.println("i=" + i + "--" + rh.score(i) + "--docid=" + rh.docid(i) + "--doc=" + rh.doc(i).get(title) );
}
query - Lucene query objectfilter - Lucene Filter objectir - Lucene IndexReader objectcollector - Lucene collector object
java.lang.ThrowableRankingHits
public int search(org.apache.lucene.search.Weight weight,
org.apache.lucene.search.Filter filter,
org.apache.lucene.index.IndexReader[] ir,
org.apache.lucene.search.Collector collector,
int[] docstart)
throws java.lang.Throwable
java.lang.Throwable
public RankingHits search(org.apache.lucene.search.Weight weight,
org.apache.lucene.search.Filter filter,
org.apache.lucene.index.IndexReader ir,
org.apache.lucene.search.Collector collector)
throws java.lang.Throwable
java.lang.Throwablepublic void addToLowerBoostSet(java.lang.String keywords)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||