Skip to content

Commit 633e603

Browse files
committed
docs: add multiple prefix and fromExisting() documentation
Added documentation for SearchIndex.fromExisting() and multiple prefix support in the getting-started guide. Changes: - New section on loading existing indices with fromExisting() - New section on multiple prefix support with YAML and Java examples - Note about prefix preservation when loading from Redis - Explanation of getPrefix() behavior with multiple prefixes Completes documentation for feat commit 3f37c52
1 parent ec4612b commit 633e603

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

core/src/main/java/com/redis/vl/schema/IndexSchema.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ public static class Index {
568568
private String name;
569569

570570
/**
571-
* The prefix(es) used for Redis keys. Can be either a String (single prefix) or List<String>
571+
* The prefix(es) used for Redis keys. Can be either a String (single prefix) or List of String
572572
* (multiple prefixes). Python port: supports Union[str, List[str]] for compatibility.
573573
*/
574574
private Object prefix;
@@ -624,12 +624,12 @@ public String getPrefix() {
624624
}
625625

626626
/**
627-
* Get the raw prefix value (can be String or List<String>).
627+
* Get the raw prefix value (can be String or List).
628628
*
629629
* <p>This method returns the prefix exactly as stored, without normalization. Use {@link
630630
* #getPrefix()} for the normalized prefix used in key construction.
631631
*
632-
* @return the raw prefix (String or List<String>), or null if not set
632+
* @return the raw prefix (String or List of String), or null if not set
633633
*/
634634
public Object getPrefixRaw() {
635635
return prefix;

docs/content/modules/ROOT/pages/getting-started.adoc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,48 @@ SearchIndex index = new SearchIndex(schema, jedis);
150150
index.create(true); // true = overwrite if exists
151151
----
152152

153+
=== Loading an Existing Index
154+
155+
If you have an existing Redis index and want to load its schema:
156+
157+
[source,java]
158+
----
159+
// Load schema from an existing Redis index
160+
SearchIndex index = SearchIndex.fromExisting("user-index", jedis);
161+
162+
// The index object now has the schema loaded from Redis
163+
IndexSchema schema = index.getSchema();
164+
System.out.println("Index name: " + schema.getIndex().getName());
165+
System.out.println("Storage type: " + schema.getIndex().getStorageType());
166+
----
167+
168+
NOTE: `fromExisting()` supports indices with multiple prefixes. If an index was created with multiple PREFIX values, all prefixes are preserved in the schema.
169+
170+
=== Multiple Prefix Support
171+
172+
RedisVL supports indices with multiple key prefixes:
173+
174+
[source,yaml]
175+
----
176+
index:
177+
name: multi-prefix-index
178+
prefix: [user, customer, account] # Multiple prefixes
179+
storage_type: json
180+
----
181+
182+
Or programmatically:
183+
184+
[source,java]
185+
----
186+
IndexSchema schema = IndexSchema.builder()
187+
.name("multi-prefix-index")
188+
.prefix(List.of("user", "customer", "account")) // Multiple prefixes
189+
.storageType(IndexSchema.StorageType.JSON)
190+
.build();
191+
----
192+
193+
When using multiple prefixes, `getPrefix()` returns the first prefix for key construction, while all prefixes are preserved for schema comparison and serialization.
194+
153195
== Load Data
154196

155197
Load your data into Redis:

0 commit comments

Comments
 (0)