Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* Node: Added `JSON.TYPE` ([#2510](https://github.com/valkey-io/valkey-glide/pull/2510))
* Java: Added `JSON.RESP` ([#2513](https://github.com/valkey-io/valkey-glide/pull/2513))
* Java: Added `JSON.TYPE` ([#2525](https://github.com/valkey-io/valkey-glide/pull/2525))
* Java: Added `FT._LIST` ([#2568](https://github.com/valkey-io/valkey-glide/pull/2568))
* Node: Added `FT.DROPINDEX` ([#2516](https://github.com/valkey-io/valkey-glide/pull/2516))
* Node: Added `JSON.RESP` ([#2517](https://github.com/valkey-io/valkey-glide/pull/2517))
* Node: Added `JSON.ARRTRIM` ([#2550](https://github.com/valkey-io/valkey-glide/pull/2550))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ public static CompletableFuture<Object[]> profile(
/**
* Returns information about a given index.
*
* @param client The client to execute the command.
* @param indexName The index name.
* @return Nested maps with info about the index. See example for more details.
* @example
Expand Down Expand Up @@ -591,6 +592,7 @@ public static CompletableFuture<Map<String, Object>> info(
/**
* Returns information about a given index.
*
* @param client The client to execute the command.
* @param indexName The index name.
* @return Nested maps with info about the index. See example for more details.
* @example
Expand Down Expand Up @@ -642,6 +644,21 @@ public static CompletableFuture<Map<String, Object>> info(
return executeCommand(client, new GlideString[] {gs("FT.INFO"), indexName}, true);
}

/**
* Lists all indexes.
*
* @param client The client to execute the command.
* @return An array of index names.
* @example
* <pre>{@code
* GlideString[] indices = FT.list(client).get();
* }</pre>
*/
public static CompletableFuture<GlideString[]> list(@NonNull BaseClient client) {
return FT.<Object[]>executeCommand(client, new GlideString[] {gs("FT._LIST")}, false)
.thenApply(arr -> castArray(arr, GlideString.class));
}

/**
* Adds an alias for an index. The new alias name can be used anywhere that an index name is
* required.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ public void ft_search() {

@SneakyThrows
@Test
public void ft_drop() {
var index = UUID.randomUUID().toString();
public void ft_drop_and_ft_list() {
var index = gs(UUID.randomUUID().toString());
assertEquals(
OK,
FT.create(
Expand All @@ -331,17 +331,11 @@ public void ft_drop() {
})
.get());

// TODO use FT.LIST with it is done
var before =
Set.of((Object[]) client.customCommand(new String[] {"FT._LIST"}).get().getSingleValue());
var before = Set.of(FT.list(client).get());

assertEquals(OK, FT.dropindex(client, index).get());

// TODO use FT.LIST with it is done
var after =
new HashSet<>(
Set.of(
(Object[]) client.customCommand(new String[] {"FT._LIST"}).get().getSingleValue()));
var after = new HashSet<>(Set.of(FT.list(client).get()));

assertFalse(after.contains(index));
after.add(index);
Expand Down