method:db = VespaStore.from_documents(docs, embedding_function, app=vespa_app, **vespa_config)retriever = db.as_retriever()query = "What did the president say about Ketanji Brown Jackson"results = retriever.get_relevant_documents(query)# results[0].metadata["id"] == "id:testapp:testapp::32"This allows for more general, unstructured, retrieval from the vector store.Metadata‚ÄãIn the example so far, we've only used the text and the embedding for that
text. Documents usually contain additional information, which in LangChain
is referred to as metadata.Vespa can contain many fields with different types by adding them to the application
package:app_package.schema.add_fields(    # ...    Field(name="date", type="string", indexing=["attribute", "summary"]),    Field(name="rating", type="int", indexing=["attribute", "summary"]),    Field(name="author", type="string", indexing=["attribute", "summary"]),    # ...)vespa_app = vespa_docker.deploy(application_package=app_package)We can add some metadata fields in the documents:# Add metadatafor i, doc in enumerate(docs):    doc.metadata["date"] = f"2023-{(i % 12)+1}-{(i % 28)+1}"    doc.metadata["rating"] = range(1, 6)[i % 5]    doc.metadata["author"] = ["Joe Biden", "Unknown"][min(i, 1)]And let the Vespa vector store know about these fields:vespa_config.update(dict(metadata_fields=["date", "rating", "author"]))Now, when searching for these documents, these fields will be returned.
Also, these fields can be filtered on:db = VespaStore.from_documents(docs, embedding_function, app=vespa_app, **vespa_config)query = "What did the president say about Ketanji Brown Jackson"results = db.similarity_search(query, filter="rating > 3")# results[0].metadata["id"] == "id:testapp:testapp::34"# results[0].metadata["author"] == "Unknown"Custom query‚ÄãIf the default behavior of the similarity search does not fit your
requirements, you can always provide your own query. Thus, you don't
Vespa is a fully featured search engine and vector database. It supports vector search (ANN), lexical search, and search in structured data, all in the same query.
Vespa is a fully featured search engine and vector database. It supports vector search (ANN), lexical search, and search in structured data, all in the same query. ->: method:db = VespaStore.from_documents(docs, embedding_function, app=vespa_app, **vespa_config)retriever = db.as_retriever()query = "What did the president say about Ketanji Brown Jackson"results = retriever.get_relevant_documents(query)# results[0].metadata["id"] == "id:testapp:testapp::32"This allows for more general, unstructured, retrieval from the vector store.Metadata‚ÄãIn the example so far, we've only used the text and the embedding for that
text. Documents usually contain additional information, which in LangChain
is referred to as metadata.Vespa can contain many fields with different types by adding them to the application
package:app_package.schema.add_fields(    # ...    Field(name="date", type="string", indexing=["attribute", "summary"]),    Field(name="rating", type="int", indexing=["attribute", "summary"]),    Field(name="author", type="string", indexing=["attribute", "summary"]),    # ...)vespa_app = vespa_docker.deploy(application_package=app_package)We can add some metadata fields in the documents:# Add metadatafor i, doc in enumerate(docs):    doc.metadata["date"] = f"2023-{(i % 12)+1}-{(i % 28)+1}"    doc.metadata["rating"] = range(1, 6)[i % 5]    doc.metadata["author"] = ["Joe Biden", "Unknown"][min(i, 1)]And let the Vespa vector store know about these fields:vespa_config.update(dict(metadata_fields=["date", "rating", "author"]))Now, when searching for these documents, these fields will be returned.
Also, these fields can be filtered on:db = VespaStore.from_documents(docs, embedding_function, app=vespa_app, **vespa_config)query = "What did the president say about Ketanji Brown Jackson"results = db.similarity_search(query, filter="rating > 3")# results[0].metadata["id"] == "id:testapp:testapp::34"# results[0].metadata["author"] == "Unknown"Custom query‚ÄãIf the default behavior of the similarity search does not fit your
requirements, you can always provide your own query. Thus, you don't