Class Store.ChunkResult

java.lang.Object
com.oracle.coherence.rag.api.Store.ChunkResult
Enclosing class:
Store

public static final class Store.ChunkResult extends Object
Represents a search result containing a document chunk with relevance score.

This class encapsulates a document chunk that matched a search query, including its content, relevance score, and the index type used for retrieval. It supports results from both vector similarity search and full-text search.

Since:
25.09
Author:
Aleks Seovic 2025.07.04
  • Constructor Summary

    Constructors
    Constructor
    Description
    ChunkResult(com.oracle.coherence.ai.QueryResult<com.oracle.coherence.ai.DocumentChunk.Id, com.oracle.coherence.ai.DocumentChunk> result)
    Creates a chunk result from a Lucene query result.
    ChunkResult(dev.langchain4j.store.embedding.EmbeddingMatch<dev.langchain4j.data.segment.TextSegment> match)
    Creates a chunk result from an embedding store match.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    Gets the unique identifier for this chunk.
    Gets the index type used to retrieve this chunk.
    double
    Gets the relevance score for this chunk.
    Gets the text content of this chunk.
    int
     
    Sets the index type for this chunk.
    setScore(double score)
    Sets the relevance score for this chunk.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ChunkResult

      public ChunkResult(dev.langchain4j.store.embedding.EmbeddingMatch<dev.langchain4j.data.segment.TextSegment> match)
      Creates a chunk result from an embedding store match.

      This constructor is used for results from vector similarity search.

      Parameters:
      match - the embedding match containing chunk and similarity score
    • ChunkResult

      public ChunkResult(com.oracle.coherence.ai.QueryResult<com.oracle.coherence.ai.DocumentChunk.Id, com.oracle.coherence.ai.DocumentChunk> result)
      Creates a chunk result from a Lucene query result.

      This constructor is used for results from full-text search.

      Parameters:
      result - the query result containing chunk and relevance score
  • Method Details

    • getChunkId

      public String getChunkId()
      Gets the unique identifier for this chunk.
      Returns:
      the chunk ID
    • getScore

      public double getScore()
      Gets the relevance score for this chunk.
      Returns:
      the relevance score (0.0 to 1.0)
    • setScore

      public Store.ChunkResult setScore(double score)
      Sets the relevance score for this chunk.

      This method is used during result processing and re-ranking.

      Parameters:
      score - the new relevance score
      Returns:
      this ChunkResult for method chaining
    • getIndex

      public String getIndex()
      Gets the index type used to retrieve this chunk.
      Returns:
      the index type (e.g., "VECTOR", "FULL_TEXT")
    • setIndex

      public Store.ChunkResult setIndex(String index)
      Sets the index type for this chunk.

      This method is used to track which search method produced this result.

      Parameters:
      index - the index type
      Returns:
      this ChunkResult for method chaining
    • getText

      public String getText()
      Gets the text content of this chunk.
      Returns:
      the chunk text content
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object