tomasloksa / azure-search-emulator

Containerized Azure Search Emulator for development purposes
MIT License
15 stars 3 forks source link

OrderBy fails if asc / desc arg is missing #36

Closed AndrewJ41 closed 2 years ago

AndrewJ41 commented 2 years ago

Solr 8.10 Screenshot 2022-02-26 at 21 38 20

When querying search results and wanting to return results without a sort order the query fails:

azuresearch           | fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
azuresearch           |       => SpanId:018e1263dfd17f49, TraceId:654b8bed30ecc9478fca1b0cc0d797ae, ParentId:e9cb1858b41f084f => ConnectionId:0HMFPCQL147F6 => RequestPath:/indexes('readacted-index')/docs/search.post.search RequestId:0HMFPCQL147F6:00000002
azuresearch           |       An unhandled exception has occurred while executing the request.
azuresearch           |       System.NullReferenceException: Object reference not set to an instance of an object.
azuresearch           |          at SearchQueryService.Controllers.SearchController.FixIdCapitalization(SearchResponse searchResult) in /src/SearchQueryService/Controllers/SearchController.cs:line 104
azuresearch           |          at SearchQueryService.Controllers.SearchController.Search(String indexName, AzSearchParams searchParams, ISearchQueryBuilder searchQueryBuilder) in /src/SearchQueryService/Controllers/SearchController.cs:line 101
azuresearch           |          at lambda_method40(Closure , Object )
azuresearch           |          at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
azuresearch           |          at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
azuresearch           |          at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
azuresearch           |          at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
azuresearch           |          at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
azuresearch           |          at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
azuresearch           |          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
azuresearch           |          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
azuresearch           |          at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
azuresearch           |          at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
azuresearch           |          at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Suggest that the default OrderBy asc is set to eliminate this

"Each clause has sort criteria, optionally followed by a sort direction (asc for ascending or desc for descending). If you don't specify a direction, the default is ascending. If there are null values in the field, null values appear first if the sort is asc and last if the sort is desc." https://docs.microsoft.com/en-gb/azure/search/search-query-odata-orderby

tomasloksa commented 2 years ago

Will be fixed soon :)

AndrewJ41 commented 2 years ago

Will be fixed soon :)

Great news! Appreciate the quick reply also.