Open levalencia opened 3 months ago
Hello @levalencia 😃
I have taken a look at the code and did some tests with my own index, and it indeed seems like the error you are encountering is due to the following line. https://github.com/langchain-ai/langchain/blob/ced5e7bae790cd9ec4e5374f5d070d9f23d6457b/libs/community/langchain_community/vectorstores/azuresearch.py#L607
I have created a PR https://github.com/langchain-ai/langchain/pull/18938 with a bit more context on what the bug is, where it comes from, and how I (hopefully) fixed it. It would be nice if you can test and confirm!
I'm running into a similar issue as well. I also have multiple metadata fields in the index - langchain should not make the assumption that there is only one metadata field, nor hard-code any names. I expect something like this to work if all of the following fields are in my index:
Document( page_content = "this is the text",
Title = "DocTitle",
Category = "Foo",
MoreMeta1 = {"x:"1, "y":2},
MoreMeta2 = {"z:"1, "q":2},
)
However in my case all I'm trying to do is add my documents to the index with add_texts or add_documents, and this is when I receive:
The property 'metadata' does not exist on type 'search.documentFields'. Make sure to only use property names that are defined by the type
Should I open a new related issue for this?
The PR you reference is changing from 'metadata' to FIELDS_ID
.
I'm pretty new here, but shouldn't this be FIELDS_TAG
?
However in my case all I'm trying to do is add my documents to the index with add_texts or add_documents, and this is when I receive:
The property 'metadata' does not exist on type 'search.documentFields'. Make sure to only use property names that are defined by the type
Should I open a new related issue for this?
Do you create the index using the AzureSearch object ? If so, I think a "metadata" field is created by default in the index definition. You can however decide to define an index yourself
Thanks for the reply. No, I create the index in a separate pipeline outside of the python code. I don't have (nor want) one particular privileged field called "metadata" (nor only one field I can override in an env var) - there are several fields in the index which hold different types of metadata that I'd like to populate and search on separately.
Also encountering this issue - and have the same set of requirements as @thelazydogsback
Checked other resources
Example Code
Custom Retriever Code
setup langchain chain,llm
My fields
Error Message and Stack Trace (if applicable)
The error is thown in this line:
When I dig deep in the langchain code, I found this code:
As you can see in the last line, its trying to find a metadata field on the search results, which we dont have as our index is customized with our own fields.
I am blaming this line: https://github.com/langchain-ai/langchain/blob/ced5e7bae790cd9ec4e5374f5d070d9f23d6457b/libs/community/langchain_community/vectorstores/azuresearch.py#L607
@Skar0 , not sure if this is really a bug, or I missed something in the documentation.
Description
I am trying to use langchain with Azure OpenAI and Azure Search as Vector Store, and a custom retriever. I dont have a metadata field
This was working with a previous project with azure-search-documents==11.4.b09 but in a new project I am trying azure-search-documents ==11.4.0
System Info
langchain==0.1.7 langchain-community==0.0.20 langchain-core==0.1.23 langchain-openai==0.0.6 langchainhub==0.1.14