Enum Class RetrievalMode
- All Implemented Interfaces:
Serializable,Comparable<RetrievalMode>,Constable
Dify retrieval modes for knowledge base search.
Different retrieval modes use different strategies to find relevant documents:
- KEYWORD_SEARCH: Traditional keyword-based search (BM25, TF-IDF)
- SEMANTIC_SEARCH: Vector-based semantic similarity search
- HYBRID_SEARCH: Combines keyword and semantic search (recommended)
- FULL_TEXT_SEARCH: Full-text search across all document content
Example usage:
DifyRAGConfig config = DifyRAGConfig.builder()
.retrievalMode(RetrievalMode.HYBRID_SEARCH) // Use hybrid search
.build();
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionFull-text search across all document content.Hybrid retrieval combining keyword and semantic approaches.Keyword-based retrieval using BM25 or similar algorithms.Semantic retrieval using vector embeddings and similarity search. -
Method Summary
Modifier and TypeMethodDescriptionstatic RetrievalModeConverts a string value to the corresponding RetrievalMode enum.getValue()Gets the string value for use in Dify API requests.toString()static RetrievalModeReturns the enum constant of this class with the specified name.static RetrievalMode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
KEYWORD_SEARCH
Keyword-based retrieval using BM25 or similar algorithms.Best for: Exact term matching, proper nouns, technical terms
-
SEMANTIC_SEARCH
Semantic retrieval using vector embeddings and similarity search.Best for: Conceptual queries, paraphrased questions, semantic understanding
-
HYBRID_SEARCH
Hybrid retrieval combining keyword and semantic approaches.This is the recommended mode as it provides the best of both worlds. Results from both methods are merged and reranked for optimal relevance.
Best for: General use, balanced precision and recall
-
FULL_TEXT_SEARCH
Full-text search across all document content.Best for: Complex queries, searching within large text bodies
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getValue
Gets the string value for use in Dify API requests.- Returns:
- the API value
-
fromValue
Converts a string value to the corresponding RetrievalMode enum.- Parameters:
value- the string value- Returns:
- the matching RetrievalMode
- Throws:
IllegalArgumentException- if the value doesn't match any mode
-
toString
- Overrides:
toStringin classEnum<RetrievalMode>
-