{
  "schema_version": 2,
  "id": "develop/clients/lettuce/vecsets",
  "title": "Vector set embeddings",
  "url": "https://redis.io/docs/latest/develop/clients/lettuce/vecsets/",
  "summary": "Index and query embeddings with Redis vector sets",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-09T09:47:45+01:00",
  "page_type": "content",
  "content_hash": "f9b5b4fdf2ede598180982309187bb90a78456874e3ab39c3f7a0ebbfdb9bc75",
  "sections": [
    {
      "id": "initialize",
      "title": "Initialize",
      "role": "content",
      "text": "If you are using [Maven](https://maven.apache.org/), add the following\ndependencies to your `pom.xml` file\n(note that you need `Lettuce` v6.8.0 or later to use vector sets):\n\n[code example]\n\nIf you are using [Gradle](https://gradle.org/), add the following\ndependencies to your `build.gradle` file:\n\n[code example]\n\nIn a new Java file, import the required classes:\n\nFoundational: Import Lettuce, DJL, and embedding model libraries for vector set operations\n\n**Difficulty:** Beginner\n\n**Available in:** Java (Asynchronous - Lettuce), Java (Reactive - Lettuce)\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n\n\nThe imports include the classes required to generate embeddings from text.\nThis example uses an instance of the `Predictor` class with the\n[`all-MiniLM-L6-v2`](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)\nmodel for the embeddings. This model generates vectors with 384 dimensions, regardless\nof the length of the input text, but note that the input is truncated to 256\ntokens (see\n[Word piece tokenization](https://huggingface.co/learn/nlp-course/en/chapter6/6)\nat the [Hugging Face](https://huggingface.co/) docs to learn more about the way tokens\nare related to the original text).\n\nPractical pattern: Initialize a DJL Predictor with the all-MiniLM-L6-v2 embedding model\n\n**Difficulty:** Beginner\n\n**Available in:** Java (Asynchronous - Lettuce), Java (Reactive - Lettuce)\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]"
    },
    {
      "id": "create-the-data",
      "title": "Create the data",
      "role": "content",
      "text": "The example data is contained in a `List<Person>` object with some brief\ndescriptions of famous people.\n\nFoundational: Define sample data with person objects containing names, descriptions, and biographical information\n\n**Difficulty:** Beginner\n\n**Available in:** Java (Asynchronous - Lettuce), Java (Reactive - Lettuce)\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]"
    },
    {
      "id": "add-the-data-to-a-vector-set",
      "title": "Add the data to a vector set",
      "role": "content",
      "text": "The next step is to connect to Redis and add the data to a new vector set.\n\nThe `predictor.predict()` method that generates the embeddings returns a `float[]` array.\nThe `vadd()` method that adds the embeddings to the vector set accepts a `Double[]` array,\nso it is useful to define a helper method to perform the conversion:\n\nFoundational: Convert float arrays to Double arrays for storing embeddings in vector sets\n\n**Difficulty:** Beginner\n\n**Available in:** Java (Asynchronous - Lettuce), Java (Reactive - Lettuce)\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n\n\nThe code below connects to Redis, then iterates through all the items in the `people` list,\ngenerates embeddings for each person's description, and then\nadds the appropriate elements to a vector set called `famousPeople`.\nNote that the `predict()` call is in a `try`/`catch` block because it can throw\nexceptions if it can't download the embedding model (you should add code to handle\nthe exceptions for production).\n\nThe call to `vadd()` also adds the `born` and `died` values from the\noriginal `people` list as attribute data. You can access this during a query\nor by using the [`vgetattr()`](https://redis.io/docs/latest/commands/vgetattr) method.\n\nFoundational: Generate embeddings and add vector data with attributes to a vector set\n\n**Difficulty:** Intermediate\n\n**Available in:** Java (Asynchronous - Lettuce), Java (Reactive - Lettuce)\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]"
    },
    {
      "id": "query-the-vector-set",
      "title": "Query the vector set",
      "role": "content",
      "text": "You can now query the data in the set. The basic approach is to use the\n`predict()` method to generate another embedding vector for the query text.\n(This is the same method used to add the elements to the set.) Then, pass\nthe query vector to [`vsim()`](https://redis.io/docs/latest/commands/vsim) to return elements\nof the set, ranked in order of similarity to the query.\n\nStart with a simple query for \"actors\":\n\nSemantic search: Execute a semantic similarity search on a vector set using text embeddings\n\n**Difficulty:** Intermediate\n\n**Available in:** Java (Asynchronous - Lettuce), Java (Reactive - Lettuce)\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n\n\nThis returns the following list of elements (formatted slightly for clarity):\n\n[code example]\n\nThe first two people in the list are the two actors, as expected, but none of the\npeople from Linus Pauling onward was especially well-known for acting (and there certainly\nisn't any information about that in the short description text).\nAs it stands, the search attempts to rank all the elements in the set, based\non the information contained in the embedding model.\nYou can use the `count` parameter of `vsim()` to limit the list of elements\nto just the most relevant few items:\n\nLimit results: Limit vector search results to the top K most similar items using the count parameter\n\n**Difficulty:** Intermediate\n\n**Available in:** Java (Asynchronous - Lettuce), Java (Reactive - Lettuce)\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n\n\nThe reason for using text embeddings rather than simple text search\nis that the embeddings represent semantic information. This allows a query\nto find elements with a similar meaning even if the text is\ndifferent. For example, the word \"entertainer\" doesn't appear in any of the\ndescriptions, but if you use it as a query, the actors and musicians are ranked\nhighest in the results list:\n\nSemantic search: Leverage text embeddings to find semantically similar items even when exact keywords don't match\n\n**Difficulty:** Intermediate\n\n**Available in:** Java (Asynchronous - Lettuce), Java (Reactive - Lettuce)\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n\n\nSimilarly, if you use \"science\" as a query, you get the following results:\n\n[code example]\n\nThe scientists are ranked highest, followed by the\nmathematicians. This ranking seems reasonable given the connection between mathematics and science.\n\nYou can also use\n[filter expressions](https://redis.io/docs/latest/develop/data-types/vector-sets/filtered-search)\nwith `vsim()` to restrict the search further. For example,\nrepeat the \"science\" query, but this time limit the results to people\nwho died before the year 2000:\n\nFiltered search: Combine vector similarity search with attribute filtering to narrow results based on metadata\n\n**Difficulty:** Advanced\n\n**Available in:** Java (Asynchronous - Lettuce), Java (Reactive - Lettuce)\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n\n\nNote that the boolean filter expression is applied to items in the list\nbefore the vector distance calculation is performed. Items that don't\npass the filter test are removed from the results completely, rather\nthan just reduced in rank. This can help to improve the performance of the\nsearch because there is no need to calculate the vector distance for\nelements that have already been filtered out of the search."
    },
    {
      "id": "more-information",
      "title": "More information",
      "role": "content",
      "text": "See the [vector sets](https://redis.io/docs/latest/develop/data-types/vector-sets)\ndocs for more information and code examples. See the\n[Redis for AI](https://redis.io/docs/latest/develop/ai) section for more details\nabout text embeddings and other AI techniques you can use with Redis.\n\nYou may also be interested in\n[vector search](https://redis.io/docs/latest/develop/clients/lettuce/vecsearch).\nThis is a feature of\n[Redis Search](https://redis.io/docs/latest/develop/ai/search-and-query)\nthat lets you retrieve\n[JSON](https://redis.io/docs/latest/develop/data-types/json) and\n[hash](https://redis.io/docs/latest/develop/data-types/hashes) documents based on\nvector data stored in their fields."
    }
  ],
  "examples": [
    {
      "id": "initialize-ex0",
      "language": "xml",
      "code": "<dependency>\n    <groupId>io.lettuce</groupId>\n    <artifactId>lettuce-core</artifactId>\n    <version>6.8.0.RELEASE</version>\n</dependency>\n\n<dependency>\n    <groupId>ai.djl.huggingface</groupId>\n    <artifactId>tokenizers</artifactId>\n    <version>0.33.0</version>\n</dependency>\n\n<dependency>\n    <groupId>ai.djl.pytorch</groupId>\n    <artifactId>pytorch-model-zoo</artifactId>\n    <version>0.33.0</version>\n</dependency>\n\n<dependency>\n    <groupId>ai.djl</groupId>\n    <artifactId>api</artifactId>\n    <version>0.33.0</version>\n</dependency>",
      "section_id": "initialize"
    },
    {
      "id": "initialize-ex1",
      "language": "bash",
      "code": "compileOnly 'io.lettuce:lettuce-core:6.8.0.RELEASE'\ncompileOnly 'ai.djl.huggingface:tokenizers:0.33.0'\ncompileOnly 'ai.djl.pytorch:pytorch-model-zoo:0.33.0'\ncompileOnly 'ai.djl:api:0.33.0'",
      "section_id": "initialize"
    },
    {
      "id": "initialize-ex2",
      "language": "java",
      "code": "// Lettuce client and Redis Search classes.\nimport io.lettuce.core.*;\nimport io.lettuce.core.api.StatefulRedisConnection;\nimport io.lettuce.core.api.async.RedisAsyncCommands;\n\n// Standard library classes for data manipulation and\n// asynchronous programming.\nimport java.util.*;\nimport java.util.concurrent.CompletableFuture;\n\n// DJL classes for model loading and inference.\nimport ai.djl.huggingface.translator.TextEmbeddingTranslatorFactory;\nimport ai.djl.inference.Predictor;\nimport ai.djl.repository.zoo.Criteria;\nimport ai.djl.training.util.ProgressBar;",
      "section_id": "initialize"
    },
    {
      "id": "initialize-ex3",
      "language": "java",
      "code": "// Lettuce client and Redis Search classes.\nimport io.lettuce.core.*;\nimport io.lettuce.core.api.StatefulRedisConnection;\nimport io.lettuce.core.api.reactive.RedisReactiveCommands;\n\n// Standard library classes for data manipulation and\n// reactive programming.\nimport java.util.*;\nimport reactor.core.publisher.Mono;\n\n// DJL classes for model loading and inference.\nimport ai.djl.huggingface.translator.TextEmbeddingTranslatorFactory;\nimport ai.djl.inference.Predictor;\nimport ai.djl.repository.zoo.Criteria;\nimport ai.djl.training.util.ProgressBar;",
      "section_id": "initialize"
    },
    {
      "id": "initialize-ex4",
      "language": "java",
      "code": "Predictor<String, float[]> predictor = null;\n\n        try {\n            Criteria<String, float[]> criteria = Criteria.builder().setTypes(String.class, float[].class)\n                    .optModelUrls(\"djl://ai.djl.huggingface.pytorch/sentence-transformers/all-MiniLM-L6-v2\")\n                    .optEngine(\"PyTorch\").optTranslatorFactory(new TextEmbeddingTranslatorFactory())\n                    .optProgress(new ProgressBar()).build();\n\n            predictor = criteria.loadModel().newPredictor();\n        } catch (Exception e) {\n            // ...\n        }",
      "section_id": "initialize"
    },
    {
      "id": "initialize-ex5",
      "language": "java",
      "code": "Predictor<String, float[]> predictor = null;\n\n        try {\n            Criteria<String, float[]> criteria = Criteria.builder().setTypes(String.class, float[].class)\n                    .optModelUrls(\"djl://ai.djl.huggingface.pytorch/sentence-transformers/all-MiniLM-L6-v2\")\n                    .optEngine(\"PyTorch\").optTranslatorFactory(new TextEmbeddingTranslatorFactory())\n                    .optProgress(new ProgressBar()).build();\n\n            predictor = criteria.loadModel().newPredictor();\n        } catch (Exception e) {\n            // ...\n        }",
      "section_id": "initialize"
    },
    {
      "id": "create-the-data-ex0",
      "language": "java",
      "code": "final class Person {\n            final String name;\n            final int born;\n            final int died;\n            final String description;\n            Person(String name, int born, int died, String description) {\n                this.name = name; this.born = born; this.died = died; this.description = description;\n            }\n        }\n\n        List<Person> people = Arrays.asList(\n            new Person(\n                \"Marie Curie\",\n                1867, 1934,\n                \"Polish-French chemist and physicist. The only person ever to win\" +\n                \" two Nobel prizes for two different sciences.\"\n            ),\n            new Person(\n                \"Linus Pauling\",\n                1901, 1994,\n                \"American chemist and peace activist. One of only two people to\" +\n                \" win two Nobel prizes in different fields (chemistry and peace).\"\n            ),\n            new Person(\n                \"Freddie Mercury\",\n                1946, 1991,\n                \"British musician, best known as the lead singer of the rock band Queen.\"\n            ),\n            new Person(\n                \"Marie Fredriksson\",\n                1958, 2019,\n                \"Swedish multi-instrumentalist, mainly known as the lead singer and\" +\n                \" keyboardist of the band Roxette.\"\n            ),\n            new Person(\n                \"Paul Erdos\",\n                1913, 1996,\n                \"Hungarian mathematician, known for his eccentric personality almost\" +\n                \" as much as his contributions to many different fields of mathematics.\"\n            ),\n            new Person(\n                \"Maryam Mirzakhani\",\n                1977, 2017,\n                \"Iranian mathematician. The first woman ever to win the Fields medal\" +\n                \" for her contributions to mathematics.\"\n            ),\n            new Person(\n                \"Masako Natsume\",\n                1957, 1985,\n                \"Japanese actress. She was very famous in Japan but was primarily\" +\n                \" known elsewhere in the world for her portrayal of Tripitaka in the\" +\n                \" TV series Monkey.\"\n            ),\n            new Person(\n                \"Chaim Topol\",\n                1935, 2023,\n                \"Israeli actor and singer, usually credited simply as 'Topol'. He was\" +\n                \" best known for his many appearances as Tevye in the musical Fiddler\" +\n                \" on the Roof.\"\n            )\n        );",
      "section_id": "create-the-data"
    },
    {
      "id": "create-the-data-ex1",
      "language": "java",
      "code": "final class Person {\n            final String name;\n            final int born;\n            final int died;\n            final String description;\n            Person(String name, int born, int died, String description) {\n                this.name = name; this.born = born; this.died = died; this.description = description;\n            }\n        }\n\n        List<Person> people = Arrays.asList(\n            new Person(\n                \"Marie Curie\",\n                1867, 1934,\n                \"Polish-French chemist and physicist. The only person ever to win\" +\n                \" two Nobel prizes for two different sciences.\"\n            ),\n            new Person(\n                \"Linus Pauling\",\n                1901, 1994,\n                \"American chemist and peace activist. One of only two people to\" +\n                \" win two Nobel prizes in different fields (chemistry and peace).\"\n            ),\n            new Person(\n                \"Freddie Mercury\",\n                1946, 1991,\n                \"British musician, best known as the lead singer of the rock band Queen.\"\n            ),\n            new Person(\n                \"Marie Fredriksson\",\n                1958, 2019,\n                \"Swedish multi-instrumentalist, mainly known as the lead singer and\" +\n                \" keyboardist of the band Roxette.\"\n            ),\n            new Person(\n                \"Paul Erdos\",\n                1913, 1996,\n                \"Hungarian mathematician, known for his eccentric personality almost\" +\n                \" as much as his contributions to many different fields of mathematics.\"\n            ),\n            new Person(\n                \"Maryam Mirzakhani\",\n                1977, 2017,\n                \"Iranian mathematician. The first woman ever to win the Fields medal\" +\n                \" for her contributions to mathematics.\"\n            ),\n            new Person(\n                \"Masako Natsume\",\n                1957, 1985,\n                \"Japanese actress. She was very famous in Japan but was primarily\" +\n                \" known elsewhere in the world for her portrayal of Tripitaka in the\" +\n                \" TV series Monkey.\"\n            ),\n            new Person(\n                \"Chaim Topol\",\n                1935, 2023,\n                \"Israeli actor and singer, usually credited simply as 'Topol'. He was\" +\n                \" best known for his many appearances as Tevye in the musical Fiddler\" +\n                \" on the Roof.\"\n            )\n        );",
      "section_id": "create-the-data"
    },
    {
      "id": "add-the-data-to-a-vector-set-ex0",
      "language": "java",
      "code": "public static Double[] convertFloatsToDoubles(float[] input) {\n        if (input == null) {\n            return null;\n        }\n\n        Double[] output = new Double[input.length];\n\n        for (int i = 0; i < input.length; i++) {\n            output[i] = Double.valueOf(input[i]);\n        }\n\n        return output;\n    }",
      "section_id": "add-the-data-to-a-vector-set"
    },
    {
      "id": "add-the-data-to-a-vector-set-ex1",
      "language": "java",
      "code": "public static Double[] convertFloatsToDoubles(float[] input) {\n        if (input == null) {\n            return null;\n        }\n\n        Double[] output = new Double[input.length];\n\n        for (int i = 0; i < input.length; i++) {\n            output[i] = Double.valueOf(input[i]);\n        }\n\n        return output;\n    }",
      "section_id": "add-the-data-to-a-vector-set"
    },
    {
      "id": "add-the-data-to-a-vector-set-ex2",
      "language": "java",
      "code": "RedisClient redisClient = RedisClient.create(\"redis://localhost:6379\");\n\n        try (StatefulRedisConnection<String, String> connection = redisClient.connect()) {\n            RedisAsyncCommands<String, String> asyncCommands = connection.async();\n\n            CompletableFuture<?>[] vaddFutures = new CompletableFuture[people.size()];\n\n            for (int i = 0; i < people.size(); i++) {\n                Person person = people.get(i);\n                Double[] embedding = null;\n\n                try {\n                    embedding = convertFloatsToDoubles(predictor.predict(person.description));\n                } catch (Exception e) {\n                    // ...\n                }\n\n                VAddArgs personArgs = VAddArgs.Builder.attributes(String.format(\"{\\\"born\\\": %d, \\\"died\\\": %d}\", person.born, person.died));\n                \n                vaddFutures[i] = asyncCommands.vadd(\"famousPeople\", person.name, personArgs, embedding)\n                        .thenApply(result -> {\n                            System.out.println(result); // >>> true\n                            return result;\n                        }).toCompletableFuture();\n            }\n            \n            CompletableFuture.allOf(vaddFutures).join();",
      "section_id": "add-the-data-to-a-vector-set"
    },
    {
      "id": "add-the-data-to-a-vector-set-ex3",
      "language": "java",
      "code": "RedisClient redisClient = RedisClient.create(\"redis://localhost:6379\");\n\n        try (StatefulRedisConnection<String, String> connection = redisClient.connect()) {\n            RedisReactiveCommands<String, String> reactiveCommands = connection.reactive();\n\n            Mono<?>[] vaddFutures = new Mono[people.size()];\n\n            for (int i = 0; i < people.size(); i++) {\n                Person person = people.get(i);\n                Double[] embedding = null;\n\n                try {\n                    embedding = convertFloatsToDoubles(predictor.predict(person.description));\n                } catch (Exception e) {\n                    // ...\n                }\n\n                VAddArgs personArgs = VAddArgs.Builder.attributes(String.format(\"{\\\"born\\\": %d, \\\"died\\\": %d}\", person.born, person.died));\n\n                vaddFutures[i] = reactiveCommands.vadd(\"famousPeople\", person.name, personArgs, embedding)\n                        .doOnNext(result -> {\n                            System.out.println(result); // >>> true\n                        });\n            }\n\n            Mono.when(vaddFutures).block();",
      "section_id": "add-the-data-to-a-vector-set"
    },
    {
      "id": "query-the-vector-set-ex0",
      "language": "java",
      "code": "Double[] actorsEmbedding = null;\n            \n            try {\n                actorsEmbedding = convertFloatsToDoubles(predictor.predict(\"actors\"));\n            } catch (Exception e) {\n                // ...\n            }\n\n            CompletableFuture<List<String>> basicQuery = asyncCommands.vsim(\"famousPeople\", actorsEmbedding)\n                    .thenApply(result -> {\n                        System.out.println(result);\n                        // >>> [Masako Natsume, Chaim Topol, Linus Pauling, Marie Fredriksson, Maryam Mirzakhani, Marie Curie, Freddie Mercury, Paul Erdos]\n                        return result;\n                    }).toCompletableFuture();",
      "section_id": "query-the-vector-set"
    },
    {
      "id": "query-the-vector-set-ex1",
      "language": "java",
      "code": "Double[] actorsEmbedding = null;\n\n            try {\n                actorsEmbedding = convertFloatsToDoubles(predictor.predict(\"actors\"));\n            } catch (Exception e) {\n                // ...\n            }\n\n            Mono<java.util.List<String>> basicQuery = reactiveCommands.vsim(\"famousPeople\", actorsEmbedding)\n                    .collectList().doOnNext(result -> {\n                        System.out.println(result);\n                        // >>> [Masako Natsume, Chaim Topol, Linus Pauling, Marie Fredriksson, Maryam Mirzakhani, Marie Curie, Freddie Mercury, Paul Erdos]\n                    });",
      "section_id": "query-the-vector-set"
    },
    {
      "id": "query-the-vector-set-ex2",
      "language": "plaintext",
      "code": "['Masako Natsume', 'Chaim Topol', 'Linus Pauling',\n'Marie Fredriksson', 'Maryam Mirzakhani', 'Marie Curie',\n'Freddie Mercury', 'Paul Erdos']",
      "section_id": "query-the-vector-set"
    },
    {
      "id": "query-the-vector-set-ex3",
      "language": "java",
      "code": "VSimArgs limitArgs = VSimArgs.Builder.count(2L);\n            \n            CompletableFuture<List<String>> limitedQuery = asyncCommands.vsim(\"famousPeople\", limitArgs, actorsEmbedding)\n                    .thenApply(result -> {\n                        System.out.println(result);\n                        // >>> [Masako Natsume, Chaim Topol]\n                        return result;\n                    }).toCompletableFuture();",
      "section_id": "query-the-vector-set"
    },
    {
      "id": "query-the-vector-set-ex4",
      "language": "java",
      "code": "VSimArgs limitArgs = VSimArgs.Builder.count(2L);\n\n            Mono<java.util.List<String>> limitedQuery = reactiveCommands.vsim(\"famousPeople\", limitArgs, actorsEmbedding)\n                    .collectList().doOnNext(result -> {\n                        System.out.println(result);\n                        // >>> [Masako Natsume, Chaim Topol]\n                    });",
      "section_id": "query-the-vector-set"
    },
    {
      "id": "query-the-vector-set-ex5",
      "language": "java",
      "code": "Double[] entertainerEmbedding = null;\n\n            try {\n                entertainerEmbedding = convertFloatsToDoubles(predictor.predict(\"entertainers\"));\n            } catch (Exception e) {\n                // ...\n            }\n\n            CompletableFuture<List<String>> entertainerQuery = asyncCommands.vsim(\"famousPeople\", entertainerEmbedding)\n                    .thenApply(result -> {\n                        System.out.println(result);\n                        // >>> [Freddie Mercury, Chaim Topol, Linus Pauling, Marie Fredriksson, Masako Natsume, Paul Erdos, Maryam Mirzakhani, Marie Curie]\n                        return result;\n                    }).toCompletableFuture();",
      "section_id": "query-the-vector-set"
    },
    {
      "id": "query-the-vector-set-ex6",
      "language": "java",
      "code": "Double[] entertainerEmbedding = null;\n\n            try {\n                entertainerEmbedding = convertFloatsToDoubles(predictor.predict(\"entertainers\"));\n            } catch (Exception e) {\n                // ...\n            }\n\n            Mono<java.util.List<String>> entertainerQuery = reactiveCommands.vsim(\"famousPeople\", entertainerEmbedding)\n                    .collectList().doOnNext(result -> {\n                        System.out.println(result);\n                        // >>> [Freddie Mercury, Chaim Topol, Linus Pauling, Marie Fredriksson, Masako Natsume, Paul Erdos, Maryam Mirzakhani, Marie Curie]\n                    });",
      "section_id": "query-the-vector-set"
    },
    {
      "id": "query-the-vector-set-ex7",
      "language": "plaintext",
      "code": "['Marie Curie', 'Linus Pauling', 'Maryam Mirzakhani',\n'Paul Erdos', 'Marie Fredriksson', 'Freddie Mercury', 'Masako Natsume',\n'Chaim Topol']",
      "section_id": "query-the-vector-set"
    },
    {
      "id": "query-the-vector-set-ex8",
      "language": "java",
      "code": "Double[] science2000Embedding = null;\n\n            try {\n                science2000Embedding = convertFloatsToDoubles(predictor.predict(\"science\"));\n            } catch (Exception e) {\n                // ...\n            }\n\n            VSimArgs filterArgs = VSimArgs.Builder.filter(\".died < 2000\");\n\n            CompletableFuture<List<String>> filteredQuery = asyncCommands.vsim(\"famousPeople\", filterArgs, science2000Embedding)\n                    .thenApply(result -> {\n                        System.out.println(result);\n                        // >>> [Marie Curie, Linus Pauling, Paul Erdos, Freddie Mercury, Masako Natsume]\n                        return result;\n                    }).toCompletableFuture();",
      "section_id": "query-the-vector-set"
    },
    {
      "id": "query-the-vector-set-ex9",
      "language": "java",
      "code": "Double[] science2000Embedding = null;\n\n            try {\n                science2000Embedding = convertFloatsToDoubles(predictor.predict(\"science\"));\n            } catch (Exception e) {\n                // ...\n            }\n\n            VSimArgs filterArgs = VSimArgs.Builder.filter(\".died < 2000\");\n\n            Mono<java.util.List<String>> filteredQuery = reactiveCommands.vsim(\"famousPeople\", filterArgs, science2000Embedding)\n                    .collectList().doOnNext(result -> {\n                        System.out.println(result);\n                        // >>> [Marie Curie, Linus Pauling, Paul Erdos, Freddie Mercury, Masako Natsume]\n                    });",
      "section_id": "query-the-vector-set"
    }
  ]
}
