Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
2.08k stars 1.2k forks source link

FeedOption disableNonStreamingOrderByQuery ignored in Cosmos Vector Search #29911

Closed magnum6actual closed 4 months ago

magnum6actual commented 4 months ago

Describe the bug I'm setting the disableNonStreamingOrderByQuery to true so that I can use vector distance in my ORDER BY clause, but I still get the error. My code:

const { resources } = await plateTargetsContainer.items
    .query(
      {
        query:
          "SELECT TOP 100 c.restaurant, c.title, c.description, c.imageUrl, c.orderUrl, VectorDistance(c.embed, @embedding) AS SimilarityScore FROM c ORDER BY VECTORDISTANCE(c.embed, @embedding)", //ORDER BY VECTORDISTANCE(c.embed, @embedding)
        parameters: [{ name: "@embedding", value: embedding }],
      },
      { disableNonStreamingOrderByQuery: true }
    )
    .fetchAll();

The error:

Executed 'Functions.queryPlates' (Failed, Id=64f50492-fd84-4c4d-bdd8-1261bb1cc2d0, Duration=6534ms)
[2024-06-05T16:57:52.304Z] System.Private.CoreLib: Exception while executing function: Functions.queryPlates. System.Private.CoreLib: Result: Failure
[2024-06-05T16:57:52.304Z] Exception: {"code":"BadRequest","message":"Query contains the following features, which the calling client does not support:\nNone NonStreamingOrderBy \r\nActivityId: d06a9c4f-6d48-4292-9b80-ef438b25d622, Windows/10.0.20348 cosmos-netstandard-sdk/3.18.0"}
[2024-06-05T16:57:52.304Z] Stack: Error: {"code":"BadRequest","message":"Query contains the following features, which the calling client does not support:\nNone NonStreamingOrderBy \r\nActivityId: d06a9c4f-6d48-4292-9b80-ef438b25d622, Windows/10.0.20348 cosmos-netstandard-sdk/3.18.0"}
[2024-06-05T16:57:52.304Z]     at httpRequest (/Users/wayneculbreth/Development/nutrios-protocol/ai-api/node_modules/@azure/cosmos/dist/index.js:10847:31)
[2024-06-05T16:57:52.304Z]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[2024-06-05T16:57:52.304Z]     at async /Users/wayneculbreth/Development/nutrios-protocol/ai-api/node_modules/@azure/cosmos/dist/index.js:10670:30
[2024-06-05T16:57:52.304Z]     at async addDignosticChild (/Users/wayneculbreth/Development/nutrios-protocol/ai-api/node_modules/@azure/cosmos/dist/index.js:3179:26)
[2024-06-05T16:57:52.304Z]     at async addDignosticChild (/Users/wayneculbreth/Development/nutrios-protocol/ai-api/node_modules/@azure/cosmos/dist/index.js:3179:26)
[2024-06-05T16:57:52.304Z]     at async ClientContext.getQueryPlan (/Users/wayneculbreth/Development/nutrios-protocol/ai-api/node_modules/@azure/cosmos/dist/index.js:11342:26)
[2024-06-05T16:57:52.304Z]     at async withMetadataDiagnostics (/Users/wayneculbreth/Development/nutrios-protocol/ai-api/node_modules/@azure/cosmos/dist/index.js:3203:26).

My package.json line:

"@azure/cosmos": "4.0.1-beta.3",

Excited about this feature in Cosmos, just need to get this working for a demo project I need to show.

@topshot99 - I saw this feature was from your PR. Hoping you can shed some light on what I need to do here.

github-actions[bot] commented 4 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @sajeetharan @simorenoh @v1k1.

sajeetharan commented 4 months ago

Hi @magnum6actual we have not released the support for native vector search yet, you can try it out after our official release which is about to happen by end of this month

magnum6actual commented 4 months ago

Wait, so the preview that I turned on in my Cosmos DB is just preview as in "We just want you to look at this not try to code with it"???

https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/vector-search

joelwright-dev commented 4 months ago

+1 what's going on here? I have the feature enabled and the docs reference it. Why can't I perform this query?

sajeetharan commented 4 months ago

@joelwright-dev the version isn't out yet, and we're updating documents ahead of schedule. We're on it and apologize for any inconvenience caused.