Error querying DocArrayInMemorySearch
Labels: name: area: vector store, name: auto:bug

### System Info

I start a jupyter notebook with

```python
file = 'OutdoorClothingCatalog_1000.csv'
loader = CSVLoader(file_path=file)

from langchain.indexes import VectorstoreIndexCreator

index = VectorstoreIndexCreator(
    vectorstore_cls=DocArrayInMemorySearch
).from_loaders([loader])

query ="Please list all your shirts with sun protection \
in a table in markdown and summarize each one."

esponse = index.query(query)
```

Unfortunately this leads to

```log
---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
[/workspaces/langchaintutorial/L4-QnA.ipynb](https://vscode-remote+codespaces-002bautomatic-002dfunicular-002dqpwv7xqr7j249j6.vscode-resource.vscode-cdn.net/workspaces/langchaintutorial/L4-QnA.ipynb) Zelle 17 line 1
----> [1](vscode-notebook-cell://codespaces%2Bautomatic-funicular-qpwv7xqr7j249j6/workspaces/langchaintutorial/L4-QnA.ipynb#X20sdnNjb2RlLXJlbW90ZQ%3D%3D?line=0) response = index.query(query)

File [/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/indexes/vectorstore.py:45](https://vscode-remote+codespaces-002bautomatic-002dfunicular-002dqpwv7xqr7j249j6.vscode-resource.vscode-cdn.net/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/indexes/vectorstore.py:45), in VectorStoreIndexWrapper.query(self, question, llm, retriever_kwargs, **kwargs)
     41 retriever_kwargs = retriever_kwargs or {}
     42 chain = RetrievalQA.from_chain_type(
     43     llm, retriever=self.vectorstore.as_retriever(**retriever_kwargs), **kwargs
     44 )
---> 45 return chain.run(question)

File [/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/chains/base.py:505](https://vscode-remote+codespaces-002bautomatic-002dfunicular-002dqpwv7xqr7j249j6.vscode-resource.vscode-cdn.net/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/chains/base.py:505), in Chain.run(self, callbacks, tags, metadata, *args, **kwargs)
    503     if len(args) != 1:
    504         raise ValueError("`run` supports only one positional argument.")
--> 505     return self(args[0], callbacks=callbacks, tags=tags, metadata=metadata)[
    506         _output_key
    507     ]
    509 if kwargs and not args:
    510     return self(kwargs, callbacks=callbacks, tags=tags, metadata=metadata)[
    511         _output_key
    512     ]

File [/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/chains/base.py:310](https://vscode-remote+codespaces-002bautomatic-002dfunicular-002dqpwv7xqr7j249j6.vscode-resource.vscode-cdn.net/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/chains/base.py:310), in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info)
    308 except BaseException as e:
    309     run_manager.on_chain_error(e)
--> 310     raise e
    311 run_manager.on_chain_end(outputs)
    312 final_outputs: Dict[str, Any] = self.prep_outputs(
    313     inputs, outputs, return_only_outputs
    314 )

File [/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/chains/base.py:304](https://vscode-remote+codespaces-002bautomatic-002dfunicular-002dqpwv7xqr7j249j6.vscode-resource.vscode-cdn.net/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/chains/base.py:304), in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info)
    297 run_manager = callback_manager.on_chain_start(
    298     dumpd(self),
    299     inputs,
    300     name=run_name,
    301 )
    302 try:
    303     outputs = (
--> 304         self._call(inputs, run_manager=run_manager)
    305         if new_arg_supported
    306         else self._call(inputs)
    307     )
    308 except BaseException as e:
    309     run_manager.on_chain_error(e)

File [/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/chains/retrieval_qa/base.py:136](https://vscode-remote+codespaces-002bautomatic-002dfunicular-002dqpwv7xqr7j249j6.vscode-resource.vscode-cdn.net/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/chains/retrieval_qa/base.py:136), in BaseRetrievalQA._call(self, inputs, run_manager)
    132 accepts_run_manager = (
    133     "run_manager" in inspect.signature(self._get_docs).parameters
    134 )
    135 if accepts_run_manager:
--> 136     docs = self._get_docs(question, run_manager=_run_manager)
    137 else:
    138     docs = self._get_docs(question)  # type: ignore[call-arg]

File [/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/chains/retrieval_qa/base.py:216](https://vscode-remote+codespaces-002bautomatic-002dfunicular-002dqpwv7xqr7j249j6.vscode-resource.vscode-cdn.net/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/chains/retrieval_qa/base.py:216), in RetrievalQA._get_docs(self, question, run_manager)
    209 def _get_docs(
    210     self,
    211     question: str,
    212     *,
    213     run_manager: CallbackManagerForChainRun,
    214 ) -> List[Document]:
    215     """Get docs."""
--> 216     return self.retriever.get_relevant_documents(
    217         question, callbacks=run_manager.get_child()
    218     )

File [/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/schema/retriever.py:211](https://vscode-remote+codespaces-002bautomatic-002dfunicular-002dqpwv7xqr7j249j6.vscode-resource.vscode-cdn.net/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/schema/retriever.py:211), in BaseRetriever.get_relevant_documents(self, query, callbacks, tags, metadata, run_name, **kwargs)
    209 except Exception as e:
    210     run_manager.on_retriever_error(e)
--> 211     raise e
    212 else:
    213     run_manager.on_retriever_end(
    214         result,
    215         **kwargs,
    216     )

File [/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/schema/retriever.py:204](https://vscode-remote+codespaces-002bautomatic-002dfunicular-002dqpwv7xqr7j249j6.vscode-resource.vscode-cdn.net/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/schema/retriever.py:204), in BaseRetriever.get_relevant_documents(self, query, callbacks, tags, metadata, run_name, **kwargs)
    202 _kwargs = kwargs if self._expects_other_args else {}
    203 if self._new_arg_supported:
--> 204     result = self._get_relevant_documents(
    205         query, run_manager=run_manager, **_kwargs
    206     )
    207 else:
    208     result = self._get_relevant_documents(query, **_kwargs)

File [/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/schema/vectorstore.py:585](https://vscode-remote+codespaces-002bautomatic-002dfunicular-002dqpwv7xqr7j249j6.vscode-resource.vscode-cdn.net/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/schema/vectorstore.py:585), in VectorStoreRetriever._get_relevant_documents(self, query, run_manager)
    581 def _get_relevant_documents(
    582     self, query: str, *, run_manager: CallbackManagerForRetrieverRun
    583 ) -> List[Document]:
    584     if self.search_type == "similarity":
--> 585         docs = self.vectorstore.similarity_search(query, **self.search_kwargs)
    586     elif self.search_type == "similarity_score_threshold":
    587         docs_and_similarities = (
    588             self.vectorstore.similarity_search_with_relevance_scores(
    589                 query, **self.search_kwargs
    590             )
    591         )

File [/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/vectorstores/docarray/base.py:127](https://vscode-remote+codespaces-002bautomatic-002dfunicular-002dqpwv7xqr7j249j6.vscode-resource.vscode-cdn.net/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/vectorstores/docarray/base.py:127), in DocArrayIndex.similarity_search(self, query, k, **kwargs)
    115 def similarity_search(
    116     self, query: str, k: int = 4, **kwargs: Any
    117 ) -> List[Document]:
    118     """Return docs most similar to query.
    119 
    120     Args:
   (...)
    125         List of Documents most similar to the query.
    126     """
--> 127     results = self.similarity_search_with_score(query, k=k, **kwargs)
    128     return [doc for doc, _ in results]

File [/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/vectorstores/docarray/base.py:106](https://vscode-remote+codespaces-002bautomatic-002dfunicular-002dqpwv7xqr7j249j6.vscode-resource.vscode-cdn.net/usr/local/python/3.10.8/lib/python3.10/site-packages/langchain/vectorstores/docarray/base.py:106), in DocArrayIndex.similarity_search_with_score(self, query, k, **kwargs)
     94 """Return docs most similar to query.
     95 
     96 Args:
   (...)
    103     Lower score represents more similarity.
    104 """
    105 query_embedding = self.embedding.embed_query(query)
--> 106 query_doc = self.doc_cls(embedding=query_embedding)  # type: ignore
    107 docs, scores = self.doc_index.find(query_doc, search_field="embedding", limit=k)
    109 result = [
    110     (Document(page_content=doc.text, metadata=doc.metadata), score)
    111     for doc, score in zip(docs, scores)
    112 ]

File [/usr/local/python/3.10.8/lib/python3.10/site-packages/pydantic/main.py:164](https://vscode-remote+codespaces-002bautomatic-002dfunicular-002dqpwv7xqr7j249j6.vscode-resource.vscode-cdn.net/usr/local/python/3.10.8/lib/python3.10/site-packages/pydantic/main.py:164), in BaseModel.__init__(__pydantic_self__, **data)
    162 # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    163 __tracebackhide__ = True
--> 164 __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)

ValidationError: 2 validation errors for DocArrayDoc
text
  Field required [type=missing, input_value={'embedding': [0.00328089... -0.021201754016760964]}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.4/v/missing
metadata
  Field required [type=missing, input_value={'embedding': [0.00328089... -0.021201754016760964]}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.4/v/missing
```


### Who can help?

@agola11 

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

```python
file = 'OutdoorClothingCatalog_1000.csv'
loader = CSVLoader(file_path=file)

from langchain.indexes import VectorstoreIndexCreator

index = VectorstoreIndexCreator(
    vectorstore_cls=DocArrayInMemorySearch
).from_loaders([loader])

query ="Please list all your shirts with sun protection \
in a table in markdown and summarize each one."

esponse = index.query(query)
```

### Expected behavior

List of articles with sun protection. The script is an example from deeplearning.ai