Module org.elasticsearch.xcore
Class MemoryIndexChunkScorer
java.lang.Object
org.elasticsearch.xpack.core.common.chunks.MemoryIndexChunkScorer
Utility class for scoring pre-determined chunks using an in-memory Lucene index.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.lucene.analysis.Analyzeranalyzer()org.apache.lucene.search.QuerybuildQuery(String queryText) ParsesqueryTextinto a boolean-OR query overCONTENT_FIELDusing this scorer's analyzer.scoreChunks(List<String> chunks, String queryText, int maxResults, boolean backfillResults) Creates an in-memory index of chunks, scores them against the query text, and returns the top results ordered by relevance.scoreChunks(List<String> chunks, org.apache.lucene.search.Query query, int maxResults, boolean backfillResults) Scores chunks against a pre-builtQuery.toString()
-
Field Details
-
CONTENT_FIELD
- See Also:
-
-
Constructor Details
-
MemoryIndexChunkScorer
public MemoryIndexChunkScorer() -
MemoryIndexChunkScorer
public MemoryIndexChunkScorer(org.apache.lucene.analysis.Analyzer analyzer) - Parameters:
analyzer- the analyzer used for indexing chunks and parsing query text.
-
-
Method Details
-
analyzer
public org.apache.lucene.analysis.Analyzer analyzer() -
buildQuery
ParsesqueryTextinto a boolean-OR query overCONTENT_FIELDusing this scorer's analyzer. Returnsnullwhen no terms survive analysis (e.g. all stop-words). -
scoreChunks
public List<ScoredChunk> scoreChunks(List<String> chunks, String queryText, int maxResults, boolean backfillResults) Creates an in-memory index of chunks, scores them against the query text, and returns the top results ordered by relevance.- Parameters:
chunks- the list of text chunks to scorequeryText- the query text to compare againstmaxResults- maximum number of results to returnbackfillResults- if true, backfills no matches with the first chunks in the list with scores of 0- Returns:
- list of scored chunks ordered by relevance
- Throws:
ElasticsearchException- on failure scoring chunks
-
scoreChunks
public List<ScoredChunk> scoreChunks(List<String> chunks, org.apache.lucene.search.Query query, int maxResults, boolean backfillResults) Scores chunks against a pre-builtQuery.- Parameters:
chunks- the list of text chunks to scorequery- the Lucene query to score against; ifnullno chunks will matchmaxResults- maximum number of results to returnbackfillResults- if true, backfills no matches with the first chunks in the list with scores of 0- Returns:
- list of scored chunks ordered by relevance
- Throws:
ElasticsearchException- on failure scoring chunks
-
toString
-