# Py Program to query using metadata. Error

**URL:** <https://discuss.elastic.co/t/py-program-to-query-using-metadata-error/372295>\
**Category:** Elasticsearch\
**Created:** [December 21, 2024, 7:20pm UTC](https://discuss.elastic.co/t/py-program-to-query-using-metadata-error/372295 "2024-12-21T19:20:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Afraim\_Joseph](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/afraim_joseph/32/140229_2.png) [@Afraim\_Joseph](https://discuss.elastic.co/u/Afraim_Joseph)\
**Post date:** [December 21, 2024, 7:20pm UTC](https://discuss.elastic.co/t/py-program-to-query-using-metadata-error/372295/1 "2024-12-21T19:20:56Z")

</div>

Hi guys, i am trying to make a very simple program to query my index through python.

this is the code

```auto
  query = {
        "query": {
            "bool": {
                "must": [
                    {"match": {"metadata.file_name": file_name}},
                    {"match": {"metadata.file_id": doc_id}},
                    {"match": {"metadata.user_id": user_id}},
                    {"match": {"metadata.page": page_num}}
                ]
            }
        }
    }

    response = await vector_store.search(
        query=query,
        search_type="similarity"
    )

```

where vector store is the initiated elastic client.

this query seems to work fine if i use it in the kibana console but in my program it is throwing an error

Error performing search: argument 'text': 'dict' object cannot be converted to 'PyString'

I have tried very long to find what is wrong but i am unable to fix it. I understand this might be more of a python issue than Elasticsearch issue but I confirmed the error is popping up from the packgage and since it is an elastic package i hope to find answers here.

please ask me if you need additional information please.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 21, 2024, 8:24pm UTC](https://discuss.elastic.co/t/py-program-to-query-using-metadata-error/372295/2 "2024-12-21T20:24:24Z")

</div>

Welcome!

In case it helps, I wrote some code here:

> <https://github.com/dadoonet/music-search/blob/main/elastic_music_search.ipynb>
