vespa-engine / vespa

AI + Data, online. https://vespa.ai
https://vespa.ai
Apache License 2.0
5.72k stars 595 forks source link

Nearest neighbor operator fails in custom searcher #27936

Closed danitico closed 1 year ago

danitico commented 1 year ago

Describe the bug We are trying to do a nearest neighbor search inside our custom searcher. We have followed indications in https://github.com/vespa-engine/vespa/issues/23875 and we confirm that we have the following:

After doing of all these, we see the following error:

Error in search reply.: NearestNeighborTerm(document_embedding_es, q): Query tensor was not found in request context. Returning empty blueprint

However doing this type of search running the query against the /search endpoint, we are able to collect the expected documents. As you can see in the following files, we are setting the same parameters for both queries but the one in the custom searcher fails.

To Reproduce Steps to reproduce the behavior:

  1. Set up a nearest neighbor operator inside a custom searcher
  2. Do a query and receive 0 results (see error)
  3. Compare the behaviour with the default /search endpoint

Expected behavior It should work correctly in both scenarios

Screenshots No applicable

Environment (please complete the following information):

Vespa version 8.202.11

Additional context https://github.com/vespa-engine/vespa/issues/23875

jobergum commented 1 year ago

We have multiple working examples of using the nearestNeighbor query item in a searcher, so we would appreciate the exact details on how to reproduce. That should consist of:

Here are a few sample apps that use the nearestNeighbor query item:

danitico commented 1 year ago

@jobergum I need to retire my words. The problem was the following:

So the behaviour for tensor type checking is different in both scenarios (custom searcher vs /search endpoint). I suppose that inside the searchers defined in the /search endpoint there must be a casting to that type

jobergum commented 1 year ago

When you use the search endpoint and pass a string tensor, that is converted to the tensor type specified in the schema or the query profile types. When using a searcher, and adding a different tensor type, this is the result.