|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectQueryProcessor
DefaultQueryProcessor
public class DefaultQueryProcessor
Takes a QueryRequest, rewrites the queries if necessary to remove stop- words and form bi-grams, then consults the index(es), and produces a QueryResult.
Nested Class Summary | |
---|---|
private static class |
DefaultQueryProcessor.DocHitMakerImpl
|
private static class |
DefaultQueryProcessor.HitQueueMakerImpl
|
Field Summary | |
---|---|
private CharMap |
accentMap
Mapping of accented chars to chars without diacritics |
private int |
chunkOverlap
Number of words a chunk shares with its successor |
private int |
chunkSize
Max size of a chunk (in words) |
private static FlippableStringComparator |
compactStringComparator
Comparator used for sorting strings in "compact" indexes |
private DocNumMap |
docNumMap
Keeps track of which chunks belong to which documents |
private float |
docScoreNorm
Document normalization factor (calculated from maxDocScore ) |
private IndexReader |
indexReader
Lucene reader from which to read index data |
private boolean |
isSparse
Whether the index is "sparse" (i.e. more than 5 chunks per doc) |
private float |
maxDocScore
Maximum document score (used to normalize scores) |
private int |
nDocsHit
Total number of documents hit (not just those that scored high) |
private WordMap |
pluralMap
Mapping of plural words to singular words |
private static HashMap |
searchers
Map of all XtfSearchers, so we can re-use them |
private static SparseStringComparator |
sparseStringComparator
Comparator used for sorting strings in "sparse" indexes |
private SpellReader |
spellReader
Fetches spelling suggestions |
private Set |
stopSet
Stop-words to remove (e.g. |
Constructor Summary | |
---|---|
DefaultQueryProcessor()
|
Method Summary | |
---|---|
private float |
applyBoost(int doc,
float score,
BoostSet boostSet,
QueryRequest req)
If a boost set was specified, boost the given document's score according to the set. |
private GroupData |
createDynamicGroup(IndexReader indexReader,
String field)
Create a dynamic group based on a field specification. |
private static PriorityQueue |
createHitQueue(IndexReader reader,
int inSize,
String sortFields,
boolean isSparse)
Creates either a standard score-sorting hit queue, or a field-sorting hit queue, depending on whether the query is to be sorted. |
private void |
finishGroup(ResultGroup group,
SnippetMaker snippetMaker,
QueryRequest req,
Weight weight,
BoostSet boostSet)
Finishes DocHits within a single group (also processes all its descendant groups.) |
private LinkedHashMap |
gatherKeywords(Query query,
Set desiredFields)
Make a list of all the terms present in the given query, grouped by field set. |
static XtfSearcher |
getXtfSearcher(String indexPath)
Get the XtfSearcher, which holds a reference to the Lucene index reader, cached chunk info, etc. |
private GroupCounts[] |
prepGroups(QueryRequest req,
BoostSet boostSet,
RecordingSearcher searcher,
Query query)
Create the GroupCounts objects for the given query request. |
QueryResult |
processRequest(QueryRequest req)
This is main entry point. |
void |
resetCache()
QueryProcessor maintains a static cache of Lucene searchers, one for each index directory. |
private void |
spellCheck(QueryRequest req,
QueryResult res,
Set tokFields)
Checks spelling of query terms, if spelling suggestion is enabled and the result falls below the cutoff threshholds. |
private boolean |
spellingImprovesResults(QueryRequest origReq,
QueryResult origRes,
Set spellFieldSet,
LinkedHashMap suggs)
Re-runs the original query, except with terms replaced by their suggestions. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static HashMap searchers
private IndexReader indexReader
private SpellReader spellReader
private DocNumMap docNumMap
private int chunkSize
private int chunkOverlap
private Set stopSet
private WordMap pluralMap
private CharMap accentMap
private boolean isSparse
private int nDocsHit
private float maxDocScore
private float docScoreNorm
maxDocScore
)
private static final SparseStringComparator sparseStringComparator
private static final FlippableStringComparator compactStringComparator
Constructor Detail |
---|
public DefaultQueryProcessor()
Method Detail |
---|
public QueryResult processRequest(QueryRequest req) throws IOException
processRequest
in class QueryProcessor
req
- The pre-parsed request to process
IOException
public static XtfSearcher getXtfSearcher(String indexPath) throws IOException
IOException
private void spellCheck(QueryRequest req, QueryResult res, Set tokFields) throws IOException
req
- Original query requestres
- Results of the querytokFields
- Set of tokenized fields (in case no field list was
specified in the query request.)
IOException
private boolean spellingImprovesResults(QueryRequest origReq, QueryResult origRes, Set spellFieldSet, LinkedHashMap suggs) throws IOException
origReq
- Original query requestorigRes
- Results of the original queryspellFieldSet
- Set of fields to rewrite terms withinsuggs
- Map of terms to their suggested replacements
IOException
private LinkedHashMap gatherKeywords(Query query, Set desiredFields)
query
- The query to traversedesiredFields
- The set of fields to limit to. If null, all
fields are considered.
private GroupCounts[] prepGroups(QueryRequest req, BoostSet boostSet, RecordingSearcher searcher, Query query) throws IOException
req
- query request containing group specsquery
- query to use to form dynamic groupssearcher
- searcher for dynamic groupsboostSet
- boost set for dynamic groups
IOException
private GroupData createDynamicGroup(IndexReader indexReader, String field) throws IOException
indexReader
- Where to get the data fromfield
- Special field name starting with "java:"
IOException
private void finishGroup(ResultGroup group, SnippetMaker snippetMaker, QueryRequest req, Weight weight, BoostSet boostSet) throws IOException
group
- Group to finishsnippetMaker
- Used to make snippets for any DocHits inside the
group.req
- Determines whether to finish with 'explain' or notweight
- Used for score explanationsboostSet
- Used for score explanations
IOException
public void resetCache()
resetCache
in class QueryProcessor
private float applyBoost(int doc, float score, BoostSet boostSet, QueryRequest req)
private static PriorityQueue createHitQueue(IndexReader reader, int inSize, String sortFields, boolean isSparse) throws IOException
reader
- will be used to read the field contentsinSize
- size of the queue (typically startDoc + maxDocs). If
this number is >= 999999, an infinitely resizing
queue will be created.sortFields
- space or comma delimited list of fields to sort byisSparse
- if index is sparse (i.e. more than 5 chunks per doc)
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |