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.09k stars 1.21k forks source link

[search] Results that are unrelated to the query are returned #30643

Open osamum opened 3 months ago

osamum commented 3 months ago

Type of issue

Code doesn't work

Description

[Enter feedback here] When I run a vector search using the code below, the results returned are unrelated to the query.

https://learn.microsoft.com/en-us/javascript/api/overview/azure/search-documents-readme?view=azure-node-latest#querying-with-vectors

For example, even if you search for a string of completely meaningless characters, you will still get results. The score in result is always 1 for both correct and irrelevant keywords, and rerankerScore is always undefined. How can I use this library to retrieve only results that are relevant to the content of user query?

Page URL

https://learn.microsoft.com/en-us/javascript/api/overview/azure/search-documents-readme?view=azure-node-latest#querying-with-vectors

Content source URL

https://github.com/MicrosoftDocs/azure-docs-sdk-node/blob/main/docs-ref-services/latest/search-documents-readme.md

Document Version Independent Id

bbdda1cc-8bcc-f451-adc3-336cdc222621

Article author

@azure-sdk

Metadata

github-actions[bot] commented 3 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @bleroy @markheff @miwelsh @tjacobhi.

osamum commented 3 months ago

I think the cause of this problem is that "*" is specified as the first argument to the searchClient.search method. Specifically, the following part:

const searchResults = await searchClient.search(*""**, {

If you replace this "*" with the keyword you want to use in your query, the score value will change correctly. In any case, I don't know what part this searchResults returns from the Azure AI Search response, but I would be happy to be able to obtain the contents of @search.answers[] from Azure AI Search.

jeremymeng commented 3 months ago

@osamum thank you for the report! We will take a look then get back to you.