# Not Getting complete results

**URL:** <https://forum.weaviate.io/t/not-getting-complete-results/277>\
**Category:** Support\
**Created:** [June 23, 2023, 11:38am UTC](https://forum.weaviate.io/t/not-getting-complete-results/277 "2023-06-23T11:38:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Learner](https://avatars.discourse-cdn.com/v4/letter/l/b782af/32.png) [@Learner](https://forum.weaviate.io/u/Learner)\
**Post date:** [June 23, 2023, 11:38am UTC](https://forum.weaviate.io/t/not-getting-complete-results/277/1 "2023-06-23T11:38:50Z")

</div>

**The main target of making the code was to pass the documents in 1 dataframe through the questions in another dataframe and find the top3 documents for each question along with their scores.**  
**Now I am only getting the questions in the output.**  
**So if anyone has any ideas please comment here.**

# Create a Weaviate client

client = weaviate.Client(  
url=“https://#####.weaviate.network”,  
auth\_client\_secret=weaviate.AuthApiKey(api\_key=“############################”),  
additional\_headers={  
“X-HuggingFace-Api-Key”: “##\_##################################”  
}  
)  
#client.schemas.delete\_all()

# Iterate over questions and documents

for \_,question\_row in df2.iterrows(): # question\_row in df2  
# Create Question object  
question = { # Questions  
“title”: question\_row[“Questions”]  
}  
uuid\_question = generate\_uuid5(question, “Question”)  
client.batch.add\_data\_object(  
data\_object=question, # Questions  
class\_name=“Question”,  
uuid=uuid\_question, #Questions  
)

```
# Iterate over documents for each question
for _,document_row in df1.iterrows():
    # Create Document object
    document = {
        "title": document_row["preprocessed_text"]
    }
    uuid_document = generate_uuid5(document, "Document")
    client.batch.add_data_object(
        data_object=document,
        class_name="Document",
        uuid=uuid_document,
    )

    # Add reference from Question to Document
    client.batch.add_reference(
        from_object_uuid=uuid_question,
        from_object_class_name="Question",
        from_property_name="documents",
        to_object_uuid=uuid_document,
        to_object_class_name="Document",
    )

```

# Create objects and references in the batch

result = client.batch.create\_objects()

# Run queries for each question

for \_, question\_row in df2.iterrows():  
question = question\_row[“Questions”]  
for \_, document\_row in df1.iterrows():  
document = document\_row[“preprocessed\_text”]

```
  query = """
  {
    Get {
      Document(
        where: {
          text: {
            vector: {
              cosineSimilarity: {
                vector: [%s]
                certainty: 0.8
              }
            }
          }
        }
        first: 3
        order: [{distance: DESC}]
      ) {
        edges {
          node {
            id
            distance
            properties {
              title
              # Include other desired properties here
            }
          }
        }
      }
    }
  }
  """ % question

url = "https://testing-gto38b37.weaviate.network"
headers = {
    "Content-Type": "application/json"
}
payload = {
    "query": json.dumps(query)
}

response = requests.post(url, headers=headers, json=payload)
response_data = response.json()
results = response_data.get("data", {}).get("Get", {}).get("Question", [])

# Print the results for each question
print(f"Results for Question: {question}")
for result in results:
    print("Document ID:", result.get("id"))
    print("Distance:", result.get("distance"))
    print()

```

---

<div class="post-metadata">

**Author:** ![jphwang](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/jphwang/32/38_2.png) [@jphwang](https://forum.weaviate.io/u/jphwang)\
**Post date:** [June 23, 2023, 8:57pm UTC](https://forum.weaviate.io/t/not-getting-complete-results/277/2 "2023-06-23T20:57:06Z")

</div>

Hi @Learner 👋

I’m not sure that the query syntax is correct. It looks very unfamiliar to me. Can you tell me how you developed this query?

I recommend that you take a look at the query examples that we provide 🙂

> **[Similarity / Vector search | Weaviate - vector database](https://weaviate.io/developers/weaviate/search/similarity)**
>
> Overview
