public class PostingListManager extends Object implements Closeable
IterablePosting
given
the MatchingQueryTerms object. Moreover, it knows how each Posting should be scored.
Plugins are also supported by PostingListManager. Each plugin class should implement the PostingListManagerPlugin interface, and be named explicitly in the matching.postinglist.manager.plugins property.
Properties:
Example Usage
Following code shows how term-at-a-time matching may occur using the PostingListManager:MatchingQueryTerms mqt; Index index; PostingListManager plm = new PostingListManager(index, index.getCollectionStatistics(), mqt); plm.prepare(false); for(int term = 0;term < plm.size(); term++) { IterablePosting ip = plm.get(term); while(ip.next() != IterablePosting.EOL) { double score = plm.score(term); int id = ip.getId(); } } plm.close();
Matching
Modifier and Type | Class and Description |
---|---|
static interface |
PostingListManager.PostingListManagerPlugin
Interface for plugins to further alter the posting lists managed by the PostingListManager
|
Modifier and Type | Field and Description |
---|---|
protected CollectionStatistics |
collectionStatistics
statistics of the collection
|
protected static boolean |
IGNORE_LOW_IDF_TERMS
A property that enables to ignore the terms with a low IDF.
|
protected Index |
index
underlying index
|
protected PostingIndex<Pointer> |
invertedIndex
inverted index of the index
|
protected Lexicon<String> |
lexicon
lexicon for the index
|
protected static org.apache.log4j.Logger |
logger |
protected int |
numTerms
number of terms
|
protected gnu.trove.TDoubleArrayList |
termKeyFreqs
String form for each term
|
protected List<WeightingModel[]> |
termModels
weighting models for each term
|
protected List<IterablePosting> |
termPostings
posting lists for each term
|
protected List<EntryStatistics> |
termStatistics
EntryStatistics for each term
|
protected List<String> |
termStrings
String form for each term
|
Modifier | Constructor and Description |
---|---|
protected |
PostingListManager(Index _index,
CollectionStatistics cs)
Create a posting list manager for the given index and statistics
|
|
PostingListManager(Index _index,
CollectionStatistics _cs,
MatchingQueryTerms mqt)
Create a posting list manager for the given index and statistics, and populated using the specified
MatchingQueryTerms.
|
|
PostingListManager(Index _index,
CollectionStatistics _cs,
MatchingQueryTerms mqt,
boolean splitSynonyms)
Create a posting list manager for the given index and statistics, and populated using the specified
MatchingQueryTerms.
|
Modifier and Type | Method and Description |
---|---|
void |
addSingleTerm(String queryTerm,
double weight,
EntryStatistics entryStats,
WeightingModel[] wmodels)
Add a single term to those to be matched for this query.
|
void |
addSingleTermAlternatives(String[] terms,
String stringForm,
double weight,
EntryStatistics[] entryStats,
WeightingModel[] wmodels)
Adds a synonym group to the matching process.
|
void |
addSingleTermAlternatives(String[] terms,
String stringForm,
double weight,
EntryStatistics entryStats,
WeightingModel[] wmodels)
Adds a synonym group to the matching process.
|
void |
close() |
double |
getKeyFrequency(int i) |
int |
getNumTerms()
Returns the number of postings lists (that are terms) for this query
|
IterablePosting |
getPosting(int i)
Returns the IterablePosting corresponding to the specified term
|
EntryStatistics |
getStatistics(int i)
Returns the EntryStatistics corresponding to the specified term
|
String |
getTerm(int i) |
static EntryStatistics |
mergeStatistics(EntryStatistics[] entryStats)
Knows how to merge several EntryStatistics for a single effective term
|
void |
prepare(boolean firstMove)
Counts the number of terms active.
|
double |
score(int i)
Returns the score using all weighting models for the current posting of the
specified term
|
int |
size()
Returns the number of posting lists for this query
|
protected static final org.apache.log4j.Logger logger
protected static boolean IGNORE_LOW_IDF_TERMS
protected final List<IterablePosting> termPostings
protected final List<WeightingModel[]> termModels
protected final List<EntryStatistics> termStatistics
protected final gnu.trove.TDoubleArrayList termKeyFreqs
protected int numTerms
protected Index index
protected PostingIndex<Pointer> invertedIndex
protected CollectionStatistics collectionStatistics
protected PostingListManager(Index _index, CollectionStatistics cs) throws IOException
IOException
public PostingListManager(Index _index, CollectionStatistics _cs, MatchingQueryTerms mqt) throws IOException
_index
- - index to obtain postings from_cs
- - collection statistics to obtainmqt
- - MatchingQueryTerms object calculated for the queryIOException
public PostingListManager(Index _index, CollectionStatistics _cs, MatchingQueryTerms mqt, boolean splitSynonyms) throws IOException
_index
- - index to obtain postings from_cs
- - collection statistics to obtainmqt
- - MatchingQueryTerms object calculated for the querysplitSynonyms
- - allows the splitting of synonym groups (i.e. singleTermAlternatives) to be disabledIOException
public void addSingleTerm(String queryTerm, double weight, EntryStatistics entryStats, WeightingModel[] wmodels) throws IOException
queryTerm
- String form of the query termweight
- influence of this query term in scoringentryStats
- statistics to be used for this query term. If null, these will be obtained
from the local Lexiconwmodels
- weighting models to be applied for this query termIOException
public static EntryStatistics mergeStatistics(EntryStatistics[] entryStats)
public void addSingleTermAlternatives(String[] terms, String stringForm, double weight, EntryStatistics[] entryStats, WeightingModel[] wmodels) throws IOException
terms
- String of the terms in the synonym groupweight
- influence of this synonym group during retrievalentryStats
- statistics of the terms in the synonym group. If null, these will
be obtained from the local Lexicon.wmodels
- WeightingModels for the synonym group (NOT one per member).IOException
public void addSingleTermAlternatives(String[] terms, String stringForm, double weight, EntryStatistics entryStats, WeightingModel[] wmodels) throws IOException
terms
- String of the terms in the synonym groupweight
- influence of this synonym group during retrievalentryStats
- statistics of the whole synonym group. If null, these will
be obtained from the local Lexicon for all terms in the group will be combined using mergeStatistics()wmodels
- WeightingModels for the synonym group (NOT one per member).IOException
public void prepare(boolean firstMove) throws IOException
firstMove
- move all postings to the start?IOException
public EntryStatistics getStatistics(int i)
i
- term to obtain statistics forpublic IterablePosting getPosting(int i)
i
- term to obtain the posting list forpublic int size()
public int getNumTerms()
public double score(int i)
i
- Which term to scorepublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public String getTerm(int i)
public double getKeyFrequency(int i)
Terrier 4.0. Copyright © 2004-2014 University of Glasgow