Skip to content

Nested join inside facet_by causes request to hang and time out #150

@kawad852

Description

@kawad852

Describe the bug

When using nested joins in facetBy that reference a second-level nested field ($variantPricing) inside $productVariants, the request consistently times out, even though the same nested structure works correctly in filterBy and includeFields.

This occurs on Typesense v30.0.rca37 and results in a client-side timeout (Future not completed) instead of a server-side validation or error response.

Working query params

{
"collection": "products",
"filterBy":
"$productVariants("
"$variantPricing(countryCode:=JO) && "
"$variantAttributeValues("
"$attributeValues("
"$attributes(id:)"
")"
")"
")",
"includeFields":
"
, "
"$productVariants("
", "
"$variantPricing(
, strategy: nest_array) as pricing, "
"$variantAttributeValues("
", "
"$attributeValues(
, $attributes(*)) as attribute, "
"strategy: nest_array"
") as attributes, "
"strategy: nest_array"
") as variants",
"facetBy": "$productVariants(status)",
}

Not working query params (times out):

{
"collection": "products",
"filterBy":
"$productVariants("
"$variantPricing(countryCode:=JO) && "
"$variantAttributeValues("
"$attributeValues("
"$attributes(id:)"
")"
")"
")",
"includeFields":
"
, "
"$productVariants("
", "
"$variantPricing(
, strategy: nest_array) as pricing, "
"$variantAttributeValues("
", "
"$attributeValues(
, $attributes(*)) as attribute, "
"strategy: nest_array"
") as attributes, "
"strategy: nest_array"
") as variants",
"facetBy": "$productVariants(status, $variantPricing(pricing.totalPrice))",
}

Steps to reproduce the behavior:

  1. Use Typesense v30.0.rca37
  2. Create a collection with nested relationships similar to:
    products, productVariants, variantPricing
  3. Run a search query where:
    filterBy uses nested joins on $productVariants → $variantPricing
    includeFields includes the same nested joins
  4. Add a facetBy clause referencing a nested field inside $variantPricing, for example:
    facetBy: "$productVariants(status, $variantPricing(pricing.totalPrice))"
  5. Execute the query

Expected behavior

The query succeeds and returns facets for productVariants.status and variantPricing.pricing.totalPrice

Actual behavior

TimeoutException after 0:00:10.000000: Future not completed

Additional context

The exact same nested structure works correctly in:
• filterBy
• includeFields
The issue appears specific to nested joins inside facetBy

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions