lemurproject.indri
Class QueryEnvironment

java.lang.Object
  extended by lemurproject.indri.QueryEnvironment

public class QueryEnvironment
extends java.lang.Object


Field Summary
protected  boolean swigCMemOwn
           
private  long swigCPtr
           
 
Constructor Summary
  QueryEnvironment()
           
protected QueryEnvironment(long cPtr, boolean cMemoryOwn)
           
 
Method Summary
 void addIndex(java.lang.String pathname)
          Add a local repository
 void addServer(java.lang.String hostname)
          Add a remote server
 void close()
          Close the QueryEnvironment.
 void delete()
           
 long documentCount()
          Return total number of documents in the collection.
 long documentCount(java.lang.String term)
          Return total number of documents in the collection for the given term.
 int[] documentIDsFromMetadata(java.lang.String attributeName, java.lang.String[] attributeValue)
          Return a list of document IDs where the document has a metadata key that matches attributeName, with a value matching one of the attributeValues.
 int documentLength(int documentID)
          Return all the length of a document.
 java.lang.String[] documentMetadata(int[] documentIDs, java.lang.String attributeName)
          Fetch the named metadata attribute for a list of document ids
 java.lang.String[] documentMetadata(ScoredExtentResult[] documentIDs, java.lang.String attributeName)
          Fetch the named metadata attribute for a list of ScoredExtentResults
 ParsedDocument[] documents(int[] documentIDs)
          Fetch the parsed documents for a given list of ScoredExtentResults
 ParsedDocument[] documents(ScoredExtentResult[] results)
          Fetch the parsed documents for a given list of ScoredExtentResults
 ParsedDocument[] documentsFromMetadata(java.lang.String attributeName, java.lang.String[] attributeValue)
          Fetch all documents with a metadata key that matches attributeName, with a value matching one of the attributeValues.
 DocumentVector[] documentVectors(int[] documentIDs)
          Fetch a document vector for a list of documents.
 double expressionCount(java.lang.String expression)
          Return the total number of times this expression appears in the collection.
 double expressionCount(java.lang.String expression, java.lang.String queryType)
          Return the total number of times this expression appears in the collection.
 ScoredExtentResult[] expressionList(java.lang.String expression)
          Return all the occurrences of this expression in the collection.
 ScoredExtentResult[] expressionList(java.lang.String expression, java.lang.String queryType)
          Return all the occurrences of this expression in the collection.
 java.lang.String[] fieldList()
          Return the list of fields.
protected  void finalize()
           
protected static long getCPtr(QueryEnvironment obj)
           
 void removeIndex(java.lang.String pathname)
          Remove a local repository
 void removeServer(java.lang.String hostname)
          Remove a remote server
 QueryAnnotation runAnnotatedQuery(java.lang.String query, int resultsRequested)
          Run an Indri query language query.
 QueryAnnotation runAnnotatedQuery(java.lang.String query, int[] documentSet, int resultsRequested)
          Run an Indri query language query on a set of documents.
 QueryResults runQuery(QueryRequest request)
          Run an Indri query request
 ScoredExtentResult[] runQuery(java.lang.String query, int resultsRequested)
          Run an Indri query language query.
 ScoredExtentResult[] runQuery(java.lang.String query, int[] documentSet, int resultsRequested)
          Run an Indri query language query on a set of documents.
 void setMemory(long memory)
          Set the amount of memory to use.
 void setScoringRules(java.lang.String[] rules)
          Set the scoring rules
 void setStopwords(java.lang.String[] stopwords)
          Set the stopword list for query processing
 long termCount()
          Return total number of terms.
 long termCount(java.lang.String term)
          Return total number of term occurrences.
 long termFieldCount(java.lang.String term, java.lang.String field)
          Return total number of term occurrences within a field.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

swigCPtr

private long swigCPtr

swigCMemOwn

protected boolean swigCMemOwn
Constructor Detail

QueryEnvironment

protected QueryEnvironment(long cPtr,
                           boolean cMemoryOwn)

QueryEnvironment

public QueryEnvironment()
Method Detail

getCPtr

protected static long getCPtr(QueryEnvironment obj)

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

delete

public void delete()

addServer

public void addServer(java.lang.String hostname)
               throws java.lang.Exception
Add a remote server

Parameters:
hostname - the host the server is running on
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

addIndex

public void addIndex(java.lang.String pathname)
              throws java.lang.Exception
Add a local repository

Parameters:
pathname - the path to the repository.
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

removeServer

public void removeServer(java.lang.String hostname)
                  throws java.lang.Exception
Remove a remote server

Parameters:
hostname - the host the server is running on
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

removeIndex

public void removeIndex(java.lang.String pathname)
                 throws java.lang.Exception
Remove a local repository

Parameters:
pathname - the path to the repository.
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

close

public void close()
           throws java.lang.Exception
Close the QueryEnvironment.

Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

setMemory

public void setMemory(long memory)
               throws java.lang.Exception
Set the amount of memory to use.

Parameters:
memory - number of bytes to allocate
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

setScoringRules

public void setScoringRules(java.lang.String[] rules)
                     throws java.lang.Exception
Set the scoring rules

Parameters:
rules - the vector of scoring rules.
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

setStopwords

public void setStopwords(java.lang.String[] stopwords)
                  throws java.lang.Exception
Set the stopword list for query processing

Parameters:
stopwords - the list of stopwords
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

runQuery

public ScoredExtentResult[] runQuery(java.lang.String query,
                                     int resultsRequested)
                              throws java.lang.Exception
Run an Indri query language query.

Parameters:
query - the query to run
resultsRequested - maximum number of results to return
Returns:
the vector of ScoredExtentResults for the query
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

runQuery

public ScoredExtentResult[] runQuery(java.lang.String query,
                                     int[] documentSet,
                                     int resultsRequested)
                              throws java.lang.Exception
Run an Indri query language query on a set of documents.

Parameters:
query - the query to run
resultsRequested - maximum number of results to return
documentSet - the list of document ids to score.
Returns:
the vector of ScoredExtentResults for the query
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

runQuery

public QueryResults runQuery(QueryRequest request)
                      throws java.lang.Exception
Run an Indri query request

Parameters:
request - the query request to run
Returns:
the QueryResults
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

runAnnotatedQuery

public QueryAnnotation runAnnotatedQuery(java.lang.String query,
                                         int resultsRequested)
                                  throws java.lang.Exception
Run an Indri query language query.

Parameters:
query - the query to run
resultsRequested - maximum number of results to return
Returns:
pointer to QueryAnnotations for the query
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

runAnnotatedQuery

public QueryAnnotation runAnnotatedQuery(java.lang.String query,
                                         int[] documentSet,
                                         int resultsRequested)
                                  throws java.lang.Exception
Run an Indri query language query on a set of documents.

Parameters:
query - the query to run
documentSet - list of document ids to score.
resultsRequested - maximum number of results to return
Returns:
pointer to QueryAnnotations for the query
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

documents

public ParsedDocument[] documents(int[] documentIDs)
                           throws java.lang.Exception
Fetch the parsed documents for a given list of ScoredExtentResults

Parameters:
documentIDs - the list of ScoredExtentResults
Returns:
the vector of ParsedDocument pointers.
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

documents

public ParsedDocument[] documents(ScoredExtentResult[] results)
                           throws java.lang.Exception
Fetch the parsed documents for a given list of ScoredExtentResults

Parameters:
results - the list of ScoredExtentResults
Returns:
the vector of ParsedDocument pointers.
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

documentMetadata

public java.lang.String[] documentMetadata(int[] documentIDs,
                                           java.lang.String attributeName)
                                    throws java.lang.Exception
Fetch the named metadata attribute for a list of document ids

Parameters:
documentIDs - the list of ids
attributeName - the name of the metadata attribute
Returns:
the vector of string values for that attribute
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

documentMetadata

public java.lang.String[] documentMetadata(ScoredExtentResult[] documentIDs,
                                           java.lang.String attributeName)
                                    throws java.lang.Exception
Fetch the named metadata attribute for a list of ScoredExtentResults

Parameters:
documentIDs - the list of ScoredExtentResults
attributeName - the name of the metadata attribute
Returns:
the vector of string values for that attribute
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

documentIDsFromMetadata

public int[] documentIDsFromMetadata(java.lang.String attributeName,
                                     java.lang.String[] attributeValue)
                              throws java.lang.Exception
Return a list of document IDs where the document has a metadata key that matches attributeName, with a value matching one of the attributeValues.

Parameters:
attributeName - the name of the metadata attribute (e.g. 'url' or 'docno')
attributeValue - values that the metadata attribute should match
Returns:
a vector of ParsedDocuments that match the given metadata criteria
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

documentsFromMetadata

public ParsedDocument[] documentsFromMetadata(java.lang.String attributeName,
                                              java.lang.String[] attributeValue)
                                       throws java.lang.Exception
Fetch all documents with a metadata key that matches attributeName, with a value matching one of the attributeValues.

Parameters:
attributeName - the name of the metadata attribute (e.g. 'url' or 'docno')
attributeValues - values that the metadata attribute should match
Returns:
a vector of ParsedDocuments that match the given metadata criteria
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

termCount

public long termCount()
               throws java.lang.Exception
Return total number of terms.

Returns:
total number of terms in the aggregated collection
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

termCount

public long termCount(java.lang.String term)
               throws java.lang.Exception
Return total number of term occurrences.

Parameters:
term - the term to count
Returns:
total frequency of this term in the aggregated collection
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

termFieldCount

public long termFieldCount(java.lang.String term,
                           java.lang.String field)
                    throws java.lang.Exception
Return total number of term occurrences within a field.

Parameters:
term - the term to count
field - the name of the field
Returns:
total frequency of this term within this field in the aggregated collection
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

fieldList

public java.lang.String[] fieldList()
                             throws java.lang.Exception
Return the list of fields.

Returns:
vector of field names.
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

documentCount

public long documentCount()
                   throws java.lang.Exception
Return total number of documents in the collection.

Returns:
total number of documents in the aggregated collection
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

documentCount

public long documentCount(java.lang.String term)
                   throws java.lang.Exception
Return total number of documents in the collection for the given term.

Parameters:
term - the term to count documents for
Returns:
total number of documents containing the term in the aggregated collection
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

documentVectors

public DocumentVector[] documentVectors(int[] documentIDs)
                                 throws java.lang.Exception
Fetch a document vector for a list of documents.

Parameters:
documentIDs - the vector of document ids.
Returns:
DocumentVector pointer for the specified document.
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

expressionCount

public double expressionCount(java.lang.String expression,
                              java.lang.String queryType)
                       throws java.lang.Exception
Return the total number of times this expression appears in the collection.

Parameters:
expression - The expression to evaluate, probably an ordered or unordered window expression
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

expressionCount

public double expressionCount(java.lang.String expression)
                       throws java.lang.Exception
Return the total number of times this expression appears in the collection.

Parameters:
expression - The expression to evaluate, probably an ordered or unordered window expression
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

expressionList

public ScoredExtentResult[] expressionList(java.lang.String expression,
                                           java.lang.String queryType)
                                    throws java.lang.Exception
Return all the occurrences of this expression in the collection. Note that the returned vector may be quite large for large collections, and therefore has the very real possibility of exhausting the memory of the machine. Use this method with discretion.

Parameters:
expression - The expression to evaluate, probably an ordered or unordered window expression
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

expressionList

public ScoredExtentResult[] expressionList(java.lang.String expression)
                                    throws java.lang.Exception
Return all the occurrences of this expression in the collection. Note that the returned vector may be quite large for large collections, and therefore has the very real possibility of exhausting the memory of the machine. Use this method with discretion.

Parameters:
expression - The expression to evaluate, probably an ordered or unordered window expression
Throws:
java.lang.Exception - if a lemur::api::Exception was thrown by the JNI library.

documentLength

public int documentLength(int documentID)
                   throws java.lang.Exception
Return all the length of a document.

Parameters:
documentID - The internal document id.
Returns:
the length of the document.
Throws:
java.lang.Exception