Package com.tnsai.knowledge
Class SearchResult
java.lang.Object
com.tnsai.knowledge.SearchResult
- All Implemented Interfaces:
Comparable<SearchResult>
Represents a search result from a knowledge base query.
Contains the matched document along with a relevance score. Higher scores indicate better matches.
Example usage:
List<SearchResult> results = knowledgeBase.search("query", 5);
for (SearchResult result : results) {
System.out.println("Score: " + result.getScore());
System.out.println("Content: " + result.getDocument().getContent());
}
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(SearchResult other) Compares by score in descending order (highest score first).booleanConvenience method to get the document content.Gets the matched document.Convenience method to get the document ID.doublegetScore()Gets the relevance score.inthashCode()toString()
-
Constructor Details
-
SearchResult
Creates a new search result.- Parameters:
document- the matched documentscore- the relevance score (higher = more relevant)
-
-
Method Details
-
getDocument
Gets the matched document.- Returns:
- the document
-
getScore
public double getScore()Gets the relevance score. Higher scores indicate more relevant results.- Returns:
- the relevance score
-
getContent
Convenience method to get the document content.- Returns:
- the document content
-
getDocumentId
Convenience method to get the document ID.- Returns:
- the document ID
-
compareTo
Compares by score in descending order (highest score first).- Specified by:
compareToin interfaceComparable<SearchResult>
-
equals
-
hashCode
public int hashCode() -
toString
-