This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.61k
stars
2.82k
forks
source link
Azure Cognitive Search's search api has different shape than .NET/JS equivalent api #18508
const { SearchClient, AzureKeyCredential } = require("@azure/search-documents");
const endpoint = 'https://diberry-search.search.windows.net'
const key = '...'
const index_name = 'good-books'
// Create a SearchClient to send queries
const client = new SearchClient(
endpoint,
index_name,
new AzureKeyCredential(key)
);
const search = async (q, top, skip) => {
// Creating SearchOptions for query
let searchOptions = {
top: top,
skip: skip,
includeTotalCount: true
};
// Sending the search request
const searchResults = await client.search(q, searchOptions);
const output = [];
for await (const result of searchResults.results) {
output.push(result);
}
return output;
};
search("code", 10, 0).then(results => {
console.log(results)
}).catch(err => console.log(err));
Run PY equivalent
import logging
import json
from azure.core.credentials import AzureKeyCredential
from azure.search.documents import SearchClient
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import SearchIndex
# Get the service endpoint and API key from the environment
endpoint = 'https://diberry-search.search.windows.net'
key = '...'
# Your index name
index_name = 'good-books'
# Create Azure SDK client
search_client = SearchClient(endpoint, index_name, AzureKeyCredential(key))
def search(q, top, skip):
returnedDocuments = search_client.search(search_text=q, top=top,skip=skip,include_total_count=True)
return json.dumps(list(returnedDocuments))
docs = search("code", 10, 0)
print(docs)
Compare output, each individual document has a different shape in python with equivalent default params when compared to .NET and JS.
The shape is important so that tuturials and quickstarts can use the same code after the results are received.
Expected behavior
Same result shape across SDK languages.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
If you want my key, just catch me on teams.
Describe the bug The search api's results for python has a shape of:
The equivalent api for JS/.NET has the shape of:
To Reproduce Steps to reproduce the behavior:
Run js
Run PY equivalent
Compare output, each individual document has a different shape in python with equivalent default params when compared to .NET and JS.
The shape is important so that tuturials and quickstarts can use the same code after the results are received.
Expected behavior Same result shape across SDK languages.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context If you want my key, just catch me on teams.