001/* 002 * Copyright (c) 2026, Oracle and/or its affiliates. 003 * 004 * Licensed under the Universal Permissive License Version 1.0 as shown at 005 * https://oss.oracle.com/licenses/upl/ 006 */ 007package com.oracle.database.selectai; 008 009import com.oracle.database.selectai.model.SelectAIException; 010import com.oracle.database.selectai.model.VectorIndexAttributes; 011 012/** 013 * Contract for Select AI vector-index lifecycle and configuration operations. 014 * <p> 015 * A vector index stores embeddings for source content so Select AI can retrieve 016 * relevant chunks and include them in model prompts for retrieval augmented 017 * generation (RAG). A {@code VectorIndex} instance can represent a vector index created by Java, 018 * PL/SQL, Python, SQL tools, or another application when the index is visible 019 * in the current schema. 020 * <p> 021 * A {@code VectorIndex} object can be configured for creation or 022 * database-backed. A configured vector index has an index name, attributes, 023 * description, status, and create options in memory, but it is not persisted 024 * until {@link #create()} succeeds. A database-backed vector index is opened 025 * from the database, listed from metadata, or successfully created through this 026 * SDK. 027 * <p> 028 * Metadata getters can return configured values before creation. Operations 029 * that execute against an existing database vector index, such as update, 030 * enable, disable, and drop, require a database-backed vector index. The SDK 031 * rejects those operations with {@link IllegalStateException} when the object 032 * is not bound to an index name or is configured for creation but has not been 033 * created yet. 034 * 035 * @see <a href="https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/select-ai-retrieval-augmented-generation.html"> 036 * Select AI with Retrieval Augmented Generation</a> 037 */ 038public interface VectorIndex { 039 /** 040 * Returns vector index name. 041 * <p> 042 * For a complete runnable sample source, see 043 * <a href="{@docRoot}/src-html/com/oracle/database/selectai/samples/vectorindex/GetVectorIndexNameSample.html"> 044 * GetVectorIndexNameSample source</a>. 045 * 046 * @return vector index name 047 */ 048 String getIndexName(); 049 050 /** 051 * Returns vector index description. 052 * <p> 053 * For a complete runnable sample source, see 054 * <a href="{@docRoot}/src-html/com/oracle/database/selectai/samples/vectorindex/GetVectorIndexDescriptionSample.html"> 055 * GetVectorIndexDescriptionSample source</a>. 056 * 057 * @return vector index description 058 */ 059 String getDescription(); 060 061 /** 062 * Returns vector index status. 063 * <p> 064 * For a configured index that has not been created yet, returns the 065 * caller-supplied create status. For an index opened from or listed from the 066 * database, refreshes metadata from the database before returning the 067 * status. 068 * For a complete runnable sample source, see 069 * <a href="{@docRoot}/src-html/com/oracle/database/selectai/samples/vectorindex/GetVectorIndexStatusSample.html"> 070 * GetVectorIndexStatusSample source</a>. 071 * 072 * @return vector index status 073 * @throws IllegalStateException when this VectorIndex instance is not bound to an index name 074 * @throws SelectAIException when current vector index metadata cannot be fetched 075 */ 076 String getStatus() throws SelectAIException; 077 078 /** 079 * Fetches and returns current vector index attributes. 080 * <p> 081 * For indexes opened from or listed from the database, this fetches current 082 * attributes from database metadata. For newly configured indexes that have 083 * not been created yet, this returns the caller-supplied create 084 * payload. 085 * For a complete runnable sample source, see 086 * <a href="{@docRoot}/src-html/com/oracle/database/selectai/samples/vectorindex/GetVectorIndexAttributesSample.html"> 087 * GetVectorIndexAttributesSample source</a>. 088 * 089 * @return vector index attributes, or {@code null} when attributes are not available 090 * @throws SelectAIException when current vector index attributes cannot be fetched 091 */ 092 VectorIndexAttributes getVectorIndexAttributes() throws SelectAIException; 093 094 /** 095 * Indicates whether create operations wait for completion. 096 * <p> 097 * This is a create-time execution option, not current database metadata. 098 * Loaded/listed indexes return {@code null}; configured indexes return the 099 * caller-supplied create option. 100 * For a complete runnable sample source, see 101 * <a href="{@docRoot}/src-html/com/oracle/database/selectai/samples/vectorindex/IsVectorIndexWaitForCompletionSample.html"> 102 * IsVectorIndexWaitForCompletionSample source</a>. 103 * 104 * @return wait-for-completion flag 105 */ 106 Boolean isWaitForCompletion(); 107 108 /** 109 * Creates the vector index in the database. 110 * <p> 111 * Creation reads source content using the configured credential, generates 112 * embeddings using the associated profile/provider, and stores the resulting 113 * vectors for later RAG prompts. 114 * For a complete runnable sample source, see 115 * <a href="{@docRoot}/src-html/com/oracle/database/selectai/samples/vectorindex/CreateVectorIndexSample.html"> 116 * CreateVectorIndexSample source</a>. 117 * 118 * @return {@code true} when create succeeds 119 * @throws IllegalStateException when this VectorIndex instance is not configured for creation 120 * @throws SelectAIException when create fails 121 */ 122 boolean create() throws SelectAIException; 123 124 /** 125 * Drops the vector index. 126 * <p> 127 * This shorthand drops both vector-index metadata and backing vector data. 128 * For a complete runnable sample source, see 129 * <a href="{@docRoot}/src-html/com/oracle/database/selectai/samples/vectorindex/DropVectorIndexSample.html"> 130 * DropVectorIndexSample source</a>. 131 * 132 * @param force when {@code true}, performs force drop if supported 133 * @return {@code true} when drop succeeds 134 * @throws IllegalStateException when this VectorIndex instance is not bound to an index name 135 * or is configured for creation but has not been created yet 136 * @throws SelectAIException when drop fails 137 */ 138 boolean drop(boolean force) throws SelectAIException; 139 140 /** 141 * Drops the vector index and controls whether backing vector data is also 142 * removed. 143 * <p> 144 * For a complete runnable sample source, see 145 * <a href="{@docRoot}/src-html/com/oracle/database/selectai/samples/vectorindex/DropVectorIndexSample.html"> 146 * DropVectorIndexSample source</a>. 147 * 148 * @param includeData when {@code true}, drops backing vector data with the index metadata; 149 * when {@code false}, drops only vector-index metadata 150 * @param force when {@code true}, performs force drop if supported 151 * @return {@code true} when drop succeeds 152 * @throws IllegalStateException when this VectorIndex instance is not bound to an index name 153 * or is configured for creation but has not been created yet 154 * @throws SelectAIException when drop fails 155 */ 156 boolean drop(boolean includeData, boolean force) throws SelectAIException; 157 158 /** 159 * Enables the vector index so Select AI can use it during RAG operations. 160 * <p> 161 * For a complete runnable sample source, see 162 * <a href="{@docRoot}/src-html/com/oracle/database/selectai/samples/vectorindex/EnableVectorIndexSample.html"> 163 * EnableVectorIndexSample source</a>. 164 * 165 * @return {@code true} when enable succeeds 166 * @throws IllegalStateException when this VectorIndex instance is not bound to an index name 167 * or is configured for creation but has not been created yet 168 * @throws SelectAIException when enable fails 169 */ 170 boolean enable() throws SelectAIException; 171 172 /** 173 * Disables the vector index so Select AI will not use it for retrieval until 174 * it is enabled again. 175 * <p> 176 * For a complete runnable sample source, see 177 * <a href="{@docRoot}/src-html/com/oracle/database/selectai/samples/vectorindex/DisableVectorIndexSample.html"> 178 * DisableVectorIndexSample source</a>. 179 * 180 * @return {@code true} when disable succeeds 181 * @throws IllegalStateException when this VectorIndex instance is not bound to an index name 182 * or is configured for creation but has not been created yet 183 * @throws SelectAIException when disable fails 184 */ 185 boolean disable() throws SelectAIException; 186 187 /** 188 * Updates vector index attributes in bulk. 189 * <p> 190 * Use this with {@link VectorIndexAttributes#updateBuilder()} when building 191 * an update-only payload. The SDK validates required Java inputs, then 192 * delegates attribute mutability rules to {@code DBMS_CLOUD_AI.UPDATE_VECTOR_INDEX} 193 * so database-version changes are honored without SDK code changes. 194 * For a complete runnable sample source, see 195 * <a href="{@docRoot}/src-html/com/oracle/database/selectai/samples/vectorindex/UpdateVectorIndexAttributesSample.html"> 196 * UpdateVectorIndexAttributesSample source</a>. 197 * 198 * @param vectorIndexAttributes attributes payload 199 * @return {@code true} when update succeeds 200 * @throws IllegalStateException when this VectorIndex instance is not bound to an index name 201 * or is configured for creation but has not been created yet 202 * @throws SelectAIException when update fails 203 */ 204 boolean update(VectorIndexAttributes vectorIndexAttributes) throws SelectAIException; 205 206 /** 207 * Updates a single vector-index attribute using normal string binding. 208 * <p> 209 * The SDK validates required Java inputs, then delegates attribute mutability 210 * rules to {@code DBMS_CLOUD_AI.UPDATE_VECTOR_INDEX}. 211 * For a complete runnable sample source, see 212 * <a href="{@docRoot}/src-html/com/oracle/database/selectai/samples/vectorindex/UpdateVectorIndexAttributeSample.html"> 213 * UpdateVectorIndexAttributeSample source</a>. 214 * 215 * @param attributeName attribute name 216 * @param attributeValue attribute value 217 * @return {@code true} when update succeeds 218 * @throws IllegalStateException when this VectorIndex instance is not bound to an index name 219 * or is configured for creation but has not been created yet 220 * @throws SelectAIException when update fails 221 */ 222 boolean update(String attributeName, String attributeValue) throws SelectAIException; 223 224 /** 225 * Updates a single vector-index attribute and optionally sends large values 226 * as character data. 227 * <p> 228 * The SDK validates required Java inputs, then delegates attribute mutability 229 * rules to {@code DBMS_CLOUD_AI.UPDATE_VECTOR_INDEX}. 230 * For a complete runnable sample source, see 231 * <a href="{@docRoot}/src-html/com/oracle/database/selectai/samples/vectorindex/UpdateVectorIndexAttributeWithClobSample.html"> 232 * UpdateVectorIndexAttributeWithClobSample source</a>. 233 * 234 * @param attributeName attribute name 235 * @param attributeValue attribute value 236 * @param useClob when {@code true}, sends value as CLOB 237 * @return {@code true} when update succeeds 238 * @throws IllegalStateException when this VectorIndex instance is not bound to an index name 239 * or is configured for creation but has not been created yet 240 * @throws SelectAIException when update fails 241 */ 242 boolean update(String attributeName, String attributeValue, boolean useClob) throws SelectAIException; 243 244}