# Unable to query pinecone vector index using filter

**URL:** <https://community.pinecone.io/t/unable-to-query-pinecone-vector-index-using-filter/2209>\
**Category:** Support\
**Tags:** vector-database\
**Created:** [June 10, 2023, 9:43pm UTC](https://community.pinecone.io/t/unable-to-query-pinecone-vector-index-using-filter/2209 "2023-06-10T21:43:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anthonyjohnarena](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/anthonyjohnarena/32/712_2.png) [@anthonyjohnarena](https://community.pinecone.io/u/anthonyjohnarena)\
**Post date:** [June 10, 2023, 9:43pm UTC](https://community.pinecone.io/t/unable-to-query-pinecone-vector-index-using-filter/2209/1 "2023-06-10T21:43:22Z")

</div>

I am having issues trying to query my pinecone index with a filter. It works without the filter however. Any help or advice would be greatly appreciated!

I have upserted into pinecone in the following way:

```auto
for doc in tqdm(docs_restaurant):
    chunks = text_splitter.split_text(str(doc.metadata))
    for i, chunk in enumerate(chunks):
        documents.append({
            'id': f'{doc.page_content}_{i}',
            'text': chunk,
            'metadata': {
                'file': 'restaurants'
            }
        })

for i in tqdm(range(0, len(documents), batch_size)):
    i_end = min(len(documents), i+batch_size)
    res = s.post(
        f"{endpoint_url}/upsert",
        headers=headers,
        json={
            "documents": documents[i:i_end]
        }
    )

```

The data is in pinecone. I can query it with no filter successfully ala:

```auto
query_response = self.index.query(
                    top_k=query.top_k,
                    vector=query.embedding,
                    filter=None,
                    include_metadata=True,
                )

```

Which returns the following:

```auto
{'matches': [{'id': 'Del Taco_0_1',
               'metadata': {'document_id': 'Del Taco_0',
                            'file': 'restaurants',
                            'text': "pic Beyond Burritos', 'Desserts & Shakes', "
                                    "'Tacos', 'Meals', '20 Under $2 Menu']}"},
               'score': 0.786260903,
               'values': []},
              {'id': 'Minos Take Out_0_1',
               'metadata': {'document_id': 'Minos Take Out_0',
                            'file': 'restaurants',
                            'text': "izers', 'Wraps & Pitas', 'Light Meals']}"},
               'score': 0.7722193,
               'values': []},
'namespace': ''
}

```

However, when I try this:

```auto
self.index.query(
top_k=query.top_k,
vector=query.embedding,
filter={'file': {'$eq': 'restaurants'}},
include_metadata=True,)

```

It returns nothing:

```auto
{'matches': [], 'namespace': ''}

```

---

<div class="post-metadata">

**Author:** ![dra](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/dra/32/171_2.png) [@dra](https://community.pinecone.io/u/dra)\
**Post date:** [June 12, 2023, 3:36am UTC](https://community.pinecone.io/t/unable-to-query-pinecone-vector-index-using-filter/2209/2 "2023-06-12T03:36:57Z")

</div>

Hi  
I could not figure out what was wrong with the code just by looking at it.

Are you getting the expected results with curl?  
I have tested it with similar data and of course it works fine.

 ![image 179](https://us1.discourse-cdn.com/flex020/uploads/pinecone/original/1X/1ea95f6d3144a7ac5be92ebcfdd361f318964ce6.png)
