public interface QueryRunner
QueryExecutor
). Implementations may use a background thread to
pre-fetch data which they then make available through the public API.
All references to documents are made by rank, i.e. the position of the
document in the list of results.
Unless there is a good reason not to (e.g. results ranking), the documents
will be returned in increasing documentID order.
QueryRunners that perform ranking will re-order the result list so that
documents are returned in decreasing score order.Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_SCORE
The default score given to all documents when actual scoring is not being
performed.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this
QueryExecutor and releases all resources used. |
List<Binding> |
getDocumentHits(long rank)
Retrieves the hits within a given result document.
|
long |
getDocumentID(long rank)
Gets the ID of a result document.
|
Serializable |
getDocumentMetadataField(long rank,
String fieldName)
Obtains an arbitrary document metadata field from the stored document data.
|
Map<String,Serializable> |
getDocumentMetadataFields(long rank,
Set<String> fieldNames)
Obtains a set of arbitrary document metadata fields from the stored
document data.
|
double |
getDocumentScore(long rank)
Get the score for a given result document.
|
long |
getDocumentsCount()
Gets the number of result documents.
|
long |
getDocumentsCountSync()
Synchronous version of
getDocumentsCount() that waits if necessary
before returning the correct result (instead of returning -1
of the value is not yet known). |
long |
getDocumentsCurrentCount()
Gets the number of result documents found so far.
|
String[][] |
getDocumentText(long rank,
int termPosition,
int length)
Gets a segment of the document text for a given document.
|
String |
getDocumentTitle(long rank)
Obtains the title for a given document.
|
String |
getDocumentURI(long rank)
Obtains the URI for a given document.
|
void |
renderDocument(long rank,
Appendable out)
Render the content of the given document, with the hits for this query
highlighted.
|
static final double DEFAULT_SCORE
long getDocumentsCount()
-1
if the search has not yet completed, the total
number of result document otherwise.long getDocumentsCountSync()
getDocumentsCount()
that waits if necessary
before returning the correct result (instead of returning -1
of the value is not yet known).long getDocumentsCurrentCount()
getDocumentsCount()
.long getDocumentID(long rank) throws IndexOutOfBoundsException, IOException
rank
- the index of the desired document in the list of documents.
This should be a value between 0 and getDocumentsCount()
-1.
If the requested document position has not yet been ranked (i.e. we know
there is a document at that position, but we don't yet know which one) then
the necessary ranking is performed before this method returns.IndexOutOfBoundsException
- is the index provided is less than zero,
or greater than getDocumentsCount()
-1.IOException
double getDocumentScore(long rank) throws IndexOutOfBoundsException, IOException
QueryEngine
(see
QueryEngine.setScorerSource(java.util.concurrent.Callable)
).rank
- the index of the desired document in the list of documents.
This should be a value between 0 and getDocumentsCount()
-1.IndexOutOfBoundsException
IOException
List<Binding> getDocumentHits(long rank) throws IndexOutOfBoundsException, IOException
rank
- the index of the desired document in the list of documents.
This should be a value between 0 and getDocumentsCount()
-1.
This method call waits until the requested data is available before
returning (document hits are being collected by a background thread).IOException
IndexOutOfBoundsException
String[][] getDocumentText(long rank, int termPosition, int length) throws IndexException, IndexOutOfBoundsException, IOException
rank
- the rank of the requested document. This should be a value
between 0 and getDocumentsCount()
-1.termPosition
- the first term requested.length
- the number of terms requested.IndexException
IndexOutOfBoundsException
IOException
String getDocumentURI(long rank) throws IndexException, IndexOutOfBoundsException, IOException
rank
- the rank for the requested document. This should be a value
between 0 and getDocumentsCount()
-1.IndexException
IndexOutOfBoundsException
IOException
String getDocumentTitle(long rank) throws IndexException, IndexOutOfBoundsException, IOException
rank
- the rank of the requested document. This should be a value
between 0 and getDocumentsCount()
-1.IndexException
IndexOutOfBoundsException
IOException
Serializable getDocumentMetadataField(long rank, String fieldName) throws IndexException, IndexOutOfBoundsException, IOException
DocumentMetadataHelper
s used at indexing time can add arbitrary
Serializable
values as metadata fields for the documents being
indexed. This method is used at search time to retrieve those values.rank
- the rank for the requested document. This should be a value
between 0 and getDocumentsCount()
-1.fieldName
- the field name for which the value is sought.IndexException
IndexOutOfBoundsException
IOException
Map<String,Serializable> getDocumentMetadataFields(long rank, Set<String> fieldNames) throws IndexException, IndexOutOfBoundsException, IOException
DocumentMetadataHelper
s used at indexing time can add arbitrary
Serializable
values as metadata fields for the documents being
indexed. This method is used at search time to retrieve those values.rank
- the rank for the requested document. This should be a value
between 0 and getDocumentsCount()
-1.fieldNames
- the names of the metadata fields for which the values are
requested.Map
linking field names with their values.IndexException
IndexOutOfBoundsException
IOException
void renderDocument(long rank, Appendable out) throws IOException, IndexException
rank
- the rank for the requested document. This should be a value
between 0 and getDocumentsCount()
-1.out
- an Appendable
to which the output is written.IOException
IndexException
void close() throws IOException
QueryExecutor
and releases all resources used.IOException
Copyright © 2021 GATE. All rights reserved.