Azure / Azure/azure-search-vector-samples

Issue : langchain sample fails

Open
#182 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
910
Forks
377
PR merge metrics
No merged PRs in 30d

Description

I tried to replicate the notebook **azure-search-vector-python-langchain-sample.ipynb** to add documents to the index.
Here the schema for index created is not provided please provide the index schema creation code for this sample.

**Example:**
I tried to create a manual schema like below and tried to add documents

**Index Schema Creation:**
fields = [
SearchField(name="id", type=SearchFieldDataType.String, key=True, sortable=True, filterable=True, facetable=True, analyzer_name="keyword"),
SearchField(name="content", type=SearchFieldDataType.String, sortable=False, filterable=False, facetable=False),
SearchField(name="page_content", type=SearchFieldDataType.String, sortable=False, filterable=False, facetable=False),
ComplexField(name="metadata",
fields=[SearchField(name="source", type=SearchFieldDataType.String),
SearchField(name="page", type=SearchFieldDataType.Int32),
]
),
SearchField(name="vector", type=SearchFieldDataType.Collection(SearchFieldDataType.Single), vector_search_dimensions=1536, vector_search_profile_name="myHnswProfile"),
]

Failed in below line of code with the mentioned error:
line of code --->

results = vector_store.add_documents(documents=file_chunks)

(**file_chunks** structure:

[Document(page_content='title:PerksPlus.pdf, PerksPlus Health and Wellness \nReimbursement Program for \nContoso Electronics Employees' metadata={'source': 'C:/Users/Surs092/Downloads/Data\\PerksPlus.pdf', 'page': 0}
]

)

Error message:
**Exception Occured () The request is invalid. Details: A 'PrimitiveValue' node with non-null value was found when trying to read the value of the property 'metadata'; however, a 'StartArray' node, a 'StartObject' node, or a 'PrimitiveValue' node with null value was expected.
Code:
Message: The request is invalid. Details: A 'PrimitiveValue' node with non-null value was found when trying to read the value of the property 'metadata'; however, a 'StartArray' node, a 'StartObject' node, or a 'PrimitiveValue' node with null value was expected. for file PerksPlus.pdf
Indexed 0 chunks**

Also, please provide sample code to create and add custom fields to the vector index

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with azure-search-vector-python-langchain-sample.ipynb and inspect the index setup alongside the vector_store.add_documents(documents=file_chunks) call. Reproduce the metadata error with the shown file_chunks structure, then verify that the sample documents the required index schema and supports the requested custom fields without the failed indexing response.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, jupyter-notebook, python
Domain
cloud, databases, search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.