@Padmavathii Vijay Hello! It seems like you have a few questions about using Azure OpenAI with Azure Cognitive Search. Let me try to help you out.
To get meaningful aggregations and long results from Cognitive Search using Open AI, you can use the REST API of Cognitive Search to query the data and then use the Open AI API to analyze the results. You can use the aggregation feature of Cognitive Search to get the average bookings per salesperson and the number of opportunities lost due to insufficient funding in the current quarter/year. For example, to get the average bookings per salesperson, you can use the following query:
https://[service name].search.windows.net/indexes/[index name]/docs?search=*&$count=true&$select=Salesperson,Bookings&$groupby=Salesperson&$top=1000&$orderby=Bookings desc&api-version=2020-06-30
This query will return the top 1000 salespeople by bookings, along with the total number of records. You can then use the Open AI API to analyze the results and get the average bookings per salesperson.
Similarly, to get the number of opportunities lost due to insufficient funding in the current quarter/year, you can use the following query:
https://[service name].search.windows.net/indexes/[index name]/docs?search=InsufficientFunding&$count=true&$filter=LostOpportunity eq true and (Quarter eq 'Q1' or Year eq '2022')&api-version=2020-06-30
This query will return the total number of opportunities lost due to insufficient funding in the current quarter/year.
Regarding your observation that Open AI never returns the same records as Cognitive Search, it's possible that the queries being used are different. Can you please provide more details on the queries being used in Open AI and Cognitive Search?
To pass ODATA common parameters such as $count to Cognitive Search from Open AI, you can include them in the query string of the REST API call. For example, to get the top 10 records where Salesperson is John Doe, you can use the following query:
https://[service name].search.windows.net/indexes/[index name]/docs?search=Salesperson:John Doe&$count=true&$top=10&api-version=2020-06-30
This query will return the top 10 records where Salesperson is John Doe, along with the total number of records. You can then use the Open AI API to analyze the results and get the information you need.