typesense-swift icon indicating copy to clipboard operation
typesense-swift copied to clipboard

Unable to use `facetBy`

Open giilby opened this issue 1 year ago • 1 comments

Description

When facetBy is specified, results cannot be decoded. I believe this is because SearchResult.facetCounts is defined as [Int]?, but the actual value of that field is an array of documents that look like this:

facet_counts": [
        {
            "counts": [
                {
                    "count": 4,
                    "highlighted": "Value A",
                    "value": "Value A"
                },
                ...
                {
                    "count": 1,
                    "highlighted": "Value B",
                    "value": "Value B"
                }
            ],
            "field_name": "some_field",
            "stats": {
                "total_values": 7
            }
        }
]

Steps to reproduce

Execute a search with one or more fields specified in facetBy.

Expected Behavior

A usable SearchResult object is returned.

Actual Behavior

A decoding exception is thrown.

Metadata

Typesense Version: 0.24.1

OS: iOS 17.0.3

giilby avatar Nov 07 '23 15:11 giilby

same issue, could you find any solution?

luciana-ezcurra avatar Feb 22 '24 03:02 luciana-ezcurra