
Pinecone Tutorial: एक ही Index में मतलब से और Exact Terms से Search करें
Also available in English: Read this article in English
Semantic search "पैसे वापस कैसे मिलेंगे?" का जवाब तो अच्छा देता है, लेकिन error E1042 वाला ticket छोड़ देता है। Pinecone के document indexes इसे ठीक करते हैं। एक ही text field को मतलब से भी और exact keywords से भी search किया जा सकता है, और embeddings Pinecone खुद बनाता है।
2026 में क्या बदला
Full-text search और नया Documents API 2 सितंबर 2026 को API version 2026-07 पर generally available हुए। Python SDK 10.1.0 (20 अक्टूबर) ने document indexes में integrated embedding जोड़ा। create_index वाला पुराना code चलता रहेगा, लेकिन यह tutorial नया तरीका इस्तेमाल करता है।
Index बनाएँ
pip install --upgrade "pinecone>=10.1.0"
export PINECONE_API_KEY="YOUR_API_KEY"
import os, time
from pinecone import Pinecone, SchemaBuilder
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
schema = (SchemaBuilder()
.add_string_field("chunk_text", full_text_search={"language": "en"}, embed={})
.build())
if not pc.indexes.exists(name="support"):
pc.indexes.create(name="support", schema=schema)
while not pc.indexes.describe(name="support").status.ready:
time.sleep(2)
index = pc.index(name="support")
खाली embed={} default model llama-text-embed-v2 को 1,024 dimensions पर इस्तेमाल करता है। Index बनने के बाद embedding setup बदला नहीं जा सकता, इसलिए सोच-समझकर चुनें।
Documents जोड़ें
index.documents.upsert(namespace="__default__", documents=[
{"_id": "1", "chunk_text": "Refund requests must be submitted within 30 days.", "category": "policy"},
{"_id": "3", "chunk_text": "Error E1042: connection timed out after 30 seconds.", "category": "log"},
])
time.sleep(10)
Schema से बाहर के fields, जैसे category, filter करने लायक metadata बन जाते हैं (हर document में 40 KB तक)। Indexing asynchronous है, इसलिए search से पहले कुछ seconds रुकें। embed field होने पर हर upsert में ज़्यादा से ज़्यादा 96 documents जाते हैं। Pinecone आपकी files के chunks नहीं बनाता, और model किसी value के सिर्फ़ पहले 2,048 tokens पढ़ता है।
दोनों तरह से search करें
def search(kind, q):
return index.documents.search(namespace="__default__", top_k=3,
score_by=[{"type": kind, "fields": ["chunk_text"], "query": q}],
include_fields=["chunk_text"]).matches
meaning = search("embed", "how do I get my money back?")
terms = search("text", "E1042")
दोनों searches में filter दिया जा सकता है, जैसे {"category": {"$eq": "policy"}}। दोनों rankings के score अलग-अलग scale पर होते हैं, इसलिए उनकी आपस में तुलना न करें। Pinecone सुझाता है कि दोनों lists को अपने code में reciprocal rank fusion (RRF) से जोड़ें।
Free plan की सीमाएँ
Starter plan में 5 indexes, 2 GB storage और हर महीने 1 million read units मिलते हैं, और यह सिर्फ़ AWS us-east-1 में चलता है। आम तौर पर इसमें हर model के लिए हर महीने 5 million embedding tokens होते हैं। 4 नवंबर से 31 दिसंबर 2026 तक यह दोगुना होकर 10 million है।
Local विकल्प के लिए हमारा Chroma RAG tutorial या RRF के साथ Qdrant hybrid search देखें। Web pages डालने के लिए Firecrawl से Markdown से शुरू करें, या Pinecone टूल पेज पर जाएँ।
स्रोत
- Pinecone quickstart, Pinecone docs
- Integrated embedding, Pinecone docs
- Pinecone 2026 changelog
- Object limits और Rate limits, Pinecone docs
- Python SDK releases (v10.0.0 से v10.3.0), GitHub
- pinecone package, PyPI
FAQ
क्या मुझे अपना embedding model चाहिए?
नहीं। Field पर embed होने पर Pinecone documents और queries दोनों को खुद embed करता है।
क्या एक field से keyword और semantic दोनों search हो सकते हैं?
हाँ। full_text_search और embed वाला string field दोनों को support करता है।
मेरा नया document search में क्यों नहीं दिख रहा?
Indexing asynchronous है। कुछ seconds रुकें, फिर दोबारा search करें।
क्या Pinecone free है?
Starter plan सीमाओं के साथ free है, जिसमें 2 GB storage और सिर्फ़ AWS us-east-1 शामिल है।