Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Range facet values not returned when filtering #1654

Open
WimVergouwe opened this issue Apr 5, 2024 · 0 comments
Open

Range facet values not returned when filtering #1654

WimVergouwe opened this issue Apr 5, 2024 · 0 comments

Comments

@WimVergouwe
Copy link

Description

As requested: copied from slack channel

Seeing a weird issue with faceting: if I use a range facet combined with a filter_by, the facet values are not returned for the ranges:

collection creation:

{
  "name": "simplefaceting_default_products",
  "fields": [
    {
      "name": "name",
      "type": "string",
      "facet": false,
      "sort": true
    },
    {
      "name": "brand",
      "type": "string",
      "facet": true,
      "sort": false
    },
    {
      "name": "price",
      "type": "float",
      "facet": true,
      "sort": false
    }
  ]
}

importing some docs:

{"id":"pd-1","name":"Keyboard","brand":"Logitech","price":49.99}
{"id":"pd-2","name":"Mouse","brand":"Logitech","price":29.99}

searching:

{
  "searches": [
    {
      "collection": "simplefaceting_default_products",
      "q": "*",
      "filter_by": "brand:=Logitech",
      "sort_by": "name:asc",
      "facet_by": "brand,price(Low:[0, 30], Medium:[30, 75], High:[75, ])",
      "max_facet_values": 100
    }
  ]
}

results - facet values for price are not returned:

{
  "results": [
    {
      "facet_counts": [
        {
          "counts": [
            {
              "count": 2,
              "highlighted": "Logitech",
              "value": "Logitech"
            }
          ],
          "field_name": "brand",
          "sampled": false,
          "stats": {
            "total_values": 1
          }
        },
        {
          "counts": [],
          "field_name": "price",
          "sampled": false,
          "stats": {
            "avg": 39.99000072479248,
            "max": 49.9900016784668,
            "min": 29.989999771118164,
            "sum": 79.980001449584961,
            "total_values": 0
          }
        }
      ],
      "found": 2,
      "hits": [
        {
          "document": {
            "brand": "Logitech",
            "id": "pd-1",
            "name": "Keyboard",
            "price": 49.99
          },
          "highlight": {},
          "highlights": []
        },
        {
          "document": {
            "brand": "Logitech",
            "id": "pd-2",
            "name": "Mouse",
            "price": 29.99
          },
          "highlight": {},
          "highlights": []
        }
      ],
      "out_of": 2,
      "page": 1,
      "request_params": {
        "collection_name": "simplefaceting_default_products",
        "first_q": "*",
        "per_page": 10,
        "q": "*"
      },
      "search_cutoff": false,
      "search_time_ms": 7
    }
  ]
}

searching without the filter:

{
  "searches": [
    {
      "collection": "simplefaceting_default_products",
      "q": "*",
      "sort_by": "name:asc",
      "facet_by": "brand,price(Low:[0, 30], Medium:[30, 75], High:[75, ])",
      "max_facet_values": 100
    }
  ]
}

results - facet values for price are returned:

{
  "results": [
    {
      "facet_counts": [
        {
          "counts": [
            {
              "count": 2,
              "highlighted": "Logitech",
              "value": "Logitech"
            }
          ],
          "field_name": "brand",
          "sampled": false,
          "stats": {
            "total_values": 1
          }
        },
        {
          "counts": [
            {
              "count": 1,
              "highlighted": "",
              "value": "Low"
            },
            {
              "count": 1,
              "highlighted": "",
              "value": "Medium"
            }
          ],
          "field_name": "price",
          "sampled": false,
          "stats": {
            "avg": 39.99000072479248,
            "max": 49.9900016784668,
            "min": 29.989999771118164,
            "sum": 79.980001449584961,
            "total_values": 2
          }
        }
      ],
      "found": 2,
      "hits": [
        {
          "document": {
            "brand": "Logitech",
            "id": "pd-1",
            "name": "Keyboard",
            "price": 49.99
          },
          "highlight": {},
          "highlights": []
        },
        {
          "document": {
            "brand": "Logitech",
            "id": "pd-2",
            "name": "Mouse",
            "price": 29.99
          },
          "highlight": {},
          "highlights": []
        }
      ],
      "out_of": 2,
      "page": 1,
      "request_params": {
        "collection_name": "simplefaceting_default_products",
        "first_q": "*",
        "per_page": 10,
        "q": "*"
      },
      "search_cutoff": false,
      "search_time_ms": 5
    }
  ]
}

Metadata

Typesense Version: 26.0

OS: testcontainers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants