Pinecone basic sample is not returning complete result

Hello,
I am following guide as a starter of pinecone:

Quickstart

It is able to create index (can see it on dashboard also), insert data and query but in response of query it is not showing any matches:

query_response: {‘matches’: , ‘namespace’: ‘ns1’}

Request:

index.query( namespace=“ns1”, vector=[0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3], top_k=3, include_values=True )

Complete sample:

import pinecone

pinecone.init(api_key=“xxxx”, environment=“gcp-starter”)

create_index = pinecone.create_index(“quickstart”, dimension=8, metric=“euclidean”)

describe_index = pinecone.describe_index(“quickstart”)

print("describe_index: ", describe_index)

index = pinecone.Index(“quickstart”)

describe_index_stats = index.describe_index_stats()

print("describe_index_stats: ", describe_index)

upsert_response = index.upsert(

vectors=[

{“id”: “vec1”, “values”: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]},

{“id”: “vec2”, “values”: [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2]},

{“id”: “vec3”, “values”: [0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3]},

{“id”: “vec4”, “values”: [0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4]}

],

namespace=“ns1”

)

print("upsert_response 1: ", upsert_response)

upsert_response = index.upsert(

vectors=[

{“id”: “vec5”, “values”: [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]},

{“id”: “vec6”, “values”: [0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6]},

{“id”: “vec7”, “values”: [0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7]},

{“id”: “vec8”, “values”: [0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8]}

],

namespace=“ns2”

)

print("upsert_response 2: ", upsert_response)

describe_index_stats = index.describe_index_stats()

print("describe_index_stats: ", describe_index)

query_response = index.query(

vector=[0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3],

top_k=3,

namespace=“ns1”,

include_values=True,

include_metadata=True

)

print("query_response: ", query_response)

del_response = pinecone.delete_index(“quickstart”)

print("del_response: ", del_response)

Any suggestion if I missed anything in sample app ?

HI @jaysharma391, are you still experiencing this same behavior if you try to create and query the index?

If so, please share where/how you are running the above code. For example, are you using a Colab notebook or running a single Python file?

Additionally, I encourage you to check out our new Quickstart guide that shows how to connect to the new API that accompanied today’s release of our serverless architecture.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.