public abstract class SearchResult extends Object implements Iterable<FoundDocument>
Learn more
The example demonstrates a typical usage of the class.
String indexFolder = "c:\\MyIndex\\";
String documentFolder = "c:\\MyDocuments\\";
// Creating an index
Index index = new Index(indexFolder);
// Indexing documents from the specified folder
index.add(documentFolder);
// Setting search options
SearchOptions options = new SearchOptions();
options.getFuzzySearch().setEnabled(true); // Enabling the fuzzy search
options.getFuzzySearch().setFuzzyAlgorithm(new TableDiscreteFunction(3)); // Setting the maximum number of differences to 3
// Search for documents containing the word 'Einstein' or the phrase 'Theory of Relativity'
SearchResult result = index.search("Einstein OR \"Theory of Relativity\"", options);
// Printing the result
System.out.println("Documents: " + result.getDocumentCount());
System.out.println("Total occurrences: " + result.getOccurrenceCount());
for (int i = 0; i < result.getDocumentCount(); i++) {
FoundDocument document = result.getFoundDocument(i);
System.out.println("\tDocument: " + document.getDocumentInfo().getFilePath());
System.out.println("\tOccurrences: " + document.getOccurrenceCount());
for (int j = 0; j < document.getFoundFields().length; j++) {
FoundDocumentField field = document.getFoundFields()[j];
System.out.println("\t\tField: " + field.getFieldName());
System.out.println("\t\tOccurrences: " + document.getOccurrenceCount());
// Printing found terms
if (field.getTerms() != null) {
for (int k = 0; k < field.getTerms().length; k++) {
System.out.println("\t\t\t" + field.getTerms()[k] + " - " + field.getTermsOccurrences()[k]);
}
}
// Printing found phrases
if (field.getTermSequences() != null) {
for (int k = 0; k < field.getTermSequences().length; k++) {
String[] terms = field.getTermSequences()[k];
String sequence = "";
for (int m = 0; m < terms.length; m++) {
sequence += terms[m] + " ";
}
System.out.println("\t\t\t" + sequence + " - " + field.getTermSequencesOccurrences()[k]);
}
}
}
}
| Constructor and Description |
|---|
SearchResult() |
| Modifier and Type | Method and Description |
|---|---|
abstract int |
getDocumentCount()
Gets the number of documents found.
|
abstract Date |
getEndTime()
Gets the end time of the search.
|
abstract FoundDocument |
getFoundDocument(int index)
Gets the found document by index.
|
abstract ChunkSearchToken |
getNextChunkSearchToken()
Gets a chunk search token for searching the next chunk.
|
abstract int |
getOccurrenceCount()
Gets the total number of occurrences found.
|
abstract double |
getSearchDuration()
Gets the search duration in seconds.
|
abstract Date |
getStartTime()
Gets the start time of the search.
|
abstract boolean |
getTruncated()
Gets a value indicating that the result is truncated.
|
abstract String |
getWarnings()
Gets a warnings describing the result.
|
abstract Iterator<FoundDocument> |
iterator()
Returns an iterator that iterates through the collection of the documents found.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic abstract int getDocumentCount()
public abstract Date getEndTime()
public abstract FoundDocument getFoundDocument(int index)
index - The index of a found document.public abstract ChunkSearchToken getNextChunkSearchToken()
public abstract int getOccurrenceCount()
public abstract double getSearchDuration()
public abstract Date getStartTime()
public abstract boolean getTruncated()
public abstract String getWarnings()
public abstract Iterator<FoundDocument> iterator()
iterator in interface Iterable<FoundDocument>Copyright © 2026. All rights reserved.