Class JSONIndexBuilder

java.lang.Object
dev.langchain4j.store.embedding.oracle.JSONIndexBuilder

public class JSONIndexBuilder extends Object

This index builder allows to configure indexes on one or several keys of the metadata column of the EmbeddingTable.

It configures a function-based index using the same function used by the store to filter using the metadata column.

  • Field Details

    • indexName

      protected String indexName
      The name of the index, or null if no name was set.
  • Method Details

    • isUnique

      public JSONIndexBuilder isUnique(boolean isUnique)
      Specify UNIQUE to indicate that the value of the column (or columns) upon which the index is based must be unique. Note that you cannot specify both UNIQUE and BITMAP.
      Parameters:
      isUnique - True if the index should be UNIQUE otherwise false;
      Returns:
      This builder.
    • isBitmap

      public JSONIndexBuilder isBitmap(boolean isBitmap)
      Specify BITMAP to indicate that index is to be created with a bitmap for each distinct key, rather than indexing each row separately.
      Parameters:
      isBitmap - True if the index should be BITMAP otherwise false;
      Returns:
      This builder.
    • key

      public JSONIndexBuilder key(String key, Class<?> keyType, JSONIndexBuilder.Order order)
      Adds a column expression to the index expression that allows to index the value of a given key of the JSON column.
      Parameters:
      key - The key to index.
      keyType - The java class of the metadata column.
      order - The order the index should be created in.
      Returns:
      This builder.
      Throws:
      IllegalArgumentException - If the key is null or empty, if the sqlType is null or if the order is null
    • build

      public Index build()
      Builds the index object configured by this builder.
      Returns:
      The index object.
    • createOption

      public JSONIndexBuilder createOption(CreateOption createOption)
      Configures the option to create (or not create) an index. The default is CreateOption.CREATE_IF_NOT_EXISTS, which means that an index will be created if an index with the same name does not already exist.
      Parameters:
      createOption - The create option.
      Returns:
      This builder.
      Throws:
      IllegalArgumentException - If createOption is null.
    • name

      public JSONIndexBuilder name(String indexName)
      Sets the index name.
      Parameters:
      indexName - The name of the index.
      Returns:
      This builder.