qdrant / go-client

Go client for Qdrant vector search engine
Apache License 2.0
161 stars 15 forks source link

Search Results Payload and Vectors Empty #23

Closed jonathan-wondereur closed 1 year ago

jonathan-wondereur commented 1 year ago

When I try even your example and try to access the payload or vectors of a result, I get an empty map and nil response.

After unfliteredSearshResult I tried:

for _, result := range unfilteredSearchResult.Result {
  log.Print("id ", result.Id)
  log.Print("payload ", result.Payload)
  log.Print("score ", result.Score)
  log.Print("version ", result.Version)
  log.Print("vectors ", result.Vectors)
}

I expected to see the payload and vector for each of the search results but instead I got this:

2023/05/23 11:02:03 id num:4
2023/05/23 11:02:03 payload map[]
2023/05/23 11:02:03 score 1.362
2023/05/23 11:02:03 version 2
2023/05/23 11:02:03 vectors <nil>
2023/05/23 11:02:03 id num:1
2023/05/23 11:02:03 payload map[]
2023/05/23 11:02:03 score 1.273
2023/05/23 11:02:03 version 2
2023/05/23 11:02:03 vectors <nil>
2023/05/23 11:02:03 id num:3
2023/05/23 11:02:03 payload map[]
2023/05/23 11:02:03 score 1.208
2023/05/23 11:02:03 version 2
2023/05/23 11:02:03 vectors <nil>
jonathan-wondereur commented 1 year ago

Related to issue #20

jonathan-wondereur commented 1 year ago

I updated my code with the response I got in an email to include the undocumented WithVectors and WithPayload but the values are still nil for me:

// Unfiltered search
unfilteredSearchResult, err := pointsClient.Search(ctx, &pb.SearchPoints{
  CollectionName: collectionName,
  Vector:         []float32{0.2, 0.1, 0.9, 0.7},
  Limit:          3,
  WithVectors: &go_client.WithVectorsSelector{
      SelectorOptions: &go_client.WithVectorsSelector_Enable{},
  },
  WithPayload: &go_client.WithPayloadSelector{
      SelectorOptions: &go_client.WithPayloadSelector_Enable{},
  },
})
if err != nil {
  log.Fatalf("Could not search points: %v", err)
} else {
  log.Printf("Found points: %s", unfilteredSearchResult.GetResult())
}

for _, result := range unfilteredSearchResult.Result {
  log.Print("id ", result.Id)
  log.Print("payload ", result.Payload)
  log.Print("score ", result.Score)
  log.Print("version ", result.Version)
  log.Print("vectors ", result.Vectors)
}
2023/05/30 14:21:36 id num:4
2023/05/30 14:21:36 payload map[]
2023/05/30 14:21:36 score 1.362
2023/05/30 14:21:36 version 2
2023/05/30 14:21:36 vectors <nil>
2023/05/30 14:21:36 id num:1
2023/05/30 14:21:36 payload map[]
2023/05/30 14:21:36 score 1.273
2023/05/30 14:21:36 version 2
2023/05/30 14:21:36 vectors <nil>
2023/05/30 14:21:36 id num:3
2023/05/30 14:21:36 payload map[]
2023/05/30 14:21:36 score 1.208
2023/05/30 14:21:36 version 2
2023/05/30 14:21:36 vectors <nil>
2023/05/30 14:21:36 Found points: [id:{num:4}  score:1.362  version:2 id:{num:2}  score:0.871  version:2]
Rendez commented 1 year ago

It is documented here, you need to pass with_vectors from the GetPoints proto definition to get the vectors included in the response. I added a couple of lines for this in the main example: https://github.com/qdrant/go-client/commit/8183f43dbe68321e42020a9853426a49ca5b9c12

Let me know if it solves your issue.

Rendez commented 1 year ago

Closing, but I'll re-open if your issue isn't solved.

jonathan-wondereur commented 1 year ago

Please reopen the issue.

  1. I tried passing with_vectors as best as I could reverse engineer from the Go client, and it is still not working.
  2. While the API documentation is there, there is no documentation of how to use this feature or that it even exists on the Go client.
Rendez commented 1 year ago

Did you have a look at my comment?

// Include all payload and vectors in the search result
WithVectors: &pb.WithVectorsSelector{SelectorOptions: &pb.WithVectorsSelector_Enable{Enable: true}},
WithPayload: &pb.WithPayloadSelector{SelectorOptions: &pb.WithPayloadSelector_Enable{Enable: true}},
jonathan-wondereur commented 1 year ago

Okay, sorry, that worked; I did not see your link to the main example there.