public async void TestOrderSearch() { // test query for order with term query var result = await _orderSearchClient.SearchOrders(new SearchRequest() { Query = new TermQuery() { QueryBody = new TermQueryBody() { Fields = new List <string>() { "order_no" }, Operator = Operator.Is, Values = new List <string>() { "00080511" } } } }); // test helper method var result2 = await _orderSearchClient.SearchOrderByOrderNo("00080511"); Assert.Equal(result2.OrderNo, result.Hits[0].Data.OrderNo); }
public static async Task <SearchResult <OrderSearchHit> > SearchOrdersBetween(this IOrderSearch service, DateTime start, DateTime end) { var request = new SearchRequest { Query = new FilteredQuery() { Body = { Query = new MatchAllQuery(), Filter = new RangeFilter() { RangeFilterBody = new RangeFilterBody() { Field = "creation_date", // OCAPI BUG: Ocapi is really picky about the format for the jobs resource (normal "o" iso8601 // conversion works fine for order search but causes a 400 for job search), so we explicitly // convert to UTC and use the Z constant From = start.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"), To = end.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") } } } }, Select = "(**)", Sorts = new List <Sort>() { new Sort() { Field = "creation_date", SortOrder = SortOrder.Asc } } }; var result = await service.SearchOrders(request); return(new SearchResult <OrderSearchHit>(request, result, service.SearchOrders)); }
public static async Task <Order> SearchOrderByOrderNo(this IOrderSearch service, string orderNo) { var result = await service.SearchOrders(new SearchRequest() { Query = new TermQuery() { QueryBody = new TermQueryBody() { Fields = new List <string>() { "order_no" }, Operator = Operator.Is, Values = new List <string>() { orderNo } } }, Count = 1 }); return(result.Count > 0 ? result.Hits[0].Data : null); }