----------------------
Yes, LlamaIndex allows you to retrieve nodes based on metadata information. You can use the
MetadataFilters
and
ExactMatchFilter
classes from the
llama_index.core.vector_stores
module to filter documents based on metadata.
Here is an example of how you can do this:
from llama_index.core.vector_stores import ExactMatchFilter, MetadataFilters
filters = MetadataFilters(
filters=[ExactMatchFilter(key="tag", value="target")]
)
retriever = index.as_retriever(
similarity_top_k=20,
filters=filters,
)
source_nodes = retriever.retrieve("What did the author do growing up?")
In this example, the
ExactMatchFilter
is used to filter nodes that have a metadata key "tag" with the value "target". The
retrieve
method of the retriever object is then used to retrieve nodes that match the query and the specified metadata filters.
You can find more information about this in the
Simple Vector Store example () from the LlamaIndex documentation.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------