solomon mulatu
05/08/2025, 7:53 AMsearchGlobally
endpoint that calls two Typesense searches:
1. executeRestaurantSearch
2. executeMenuItemSearch
Problem:
- ✅ Both service calls work individually (tested by commenting out one at a time).
- ❌ When called together, we get a 400
error:
"Request failed with HTTP code 400 | Server said: Only upto 3 sort fields are allowed."
async searchGlobally(
@Args() { params, location, maximumDeliveryTime }: SearchEngineSearchDefaultMenuItemRequestDto
) {
const restaurantSearchResponse = await this.searchEngineService.executeRestaurantSearch(params, location, maximumDeliveryTime);
const menuItemSearchResponse = await this.searchEngineService.executeMenuItemSearch(params, location, maximumDeliveryTime);
// ... return combined results
}
Suspected Cause:
- The params
object passed to both services is shared/mutated, causing unintended sort field accumulation.
- Example: If executeRestaurantSearch
adds 2 sort fields and executeMenuItemSearch
adds 2 more, the second call might inherit the first’s sort fields.
What We’ve Tried:
1. Validated that each service works in isolation.
2. Confirmed that params
is not explicitly modified in the controller.
Questions:
1. Has anyone encountered this "3 sort fields" limitation in Typesense when chaining queries?
2. How can we ensure params
(especially sort_by
) is isolated between service calls?
- Should we deep-clone params
before passing to each service?
- Or is there a configuration in `executeRestaurantSearch`/`executeMenuItemSearch` that might be appending sort fields?