This message was deleted.
# community-help
s
This message was deleted.
j
Hmm, could you give me a simple script like this that creates a sample schema, adds a few sample docs and does a search query that replicates this issue?
v
Hi @Jason Bosco hope this works:
Copy code
export TYPESENSE_API_KEY=dummyAdminKeyToBeChanged

curl "http://localhost:8108/debug" \
       -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}"


curl "http://localhost:8108/collections" \
       -X POST \
       -H "Content-Type: application/json" \
       -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
       -d '{
         "name": "product_variants",
         "fields": [
           {"name": "discountPercentage", "type": "float", "facet": true },
           {"name": "productSlug", "type": "string", "facet": true },
           {"name": "variantID", "type": "int32"}
         ]
       }'

curl "http://localhost:8108/collections/product_variants/documents/import?action=create" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -H "Content-Type: text/plain" \
        -X POST \
        -d '{"id": "124","discountPercentage": 10,"productSlug": "first","variantID": 1}
            {"id": "125","discountPercentage": 20,"productSlug": "first","variantID": 2}
            {"id": "126","discountPercentage": 30,"productSlug": "second","variantID": 3}
            {"id": "127","discountPercentage": 25,"productSlug": "second","variantID": 4}
            {"id": "128","discountPercentage": 60,"productSlug": "third","variantID": 5}
            {"id": "129","discountPercentage": 70,"productSlug": "third","variantID": 6}'


# without group_by
curl --location --globoff 'http://localhost:8108/collections/product_variants/documents/search?q=*&query_by=productSlug&per_page=0&facet_by=discountPercentage(average%3A[0%2C30]%2Cgood%3A[30%2C70]%2Cgreat%3A[70%2C100])' \
--header "x-typesense-api-key: ${TYPESENSE_API_KEY}"

# with group_by
curl --location --globoff 'http://localhost:8108/collections/product_variants/documents/search?q=*&query_by=productSlug&per_page=0&group_by=productSlug&facet_by=discountPercentage(average%3A[0%2C30]%2Cgood%3A[30%2C70]%2Cgreat%3A[70%2C100])' \
--header "x-typesense-api-key: ${TYPESENSE_API_KEY}"
and these are the results when I run them
Copy code
curl --location --globoff 'http://localhost:8108/collections/product_variants/documents/search?q=*&query_by=productSlug&per_page=0&facet_by=discountPercentage(average%3A[0%2C30]%2Cgood%3A[30%2C70]%2Cgreat%3A[70%2C100])' \
--header "x-typesense-api-key: ${TYPESENSE_API_KEY}"

# with group_by
curl --location --globoff 'http://localhost:8108/collections/product_variants/documents/search?q=*&query_by=productSlug&per_page=0&group_by=productSlug&facet_by=discountPercentage(average%3A[0%2C30]%2Cgood%3A[30%2C70]%2Cgreat%3A[70%2C100])' \
--header "x-typesense-api-key: ${TYPESENSE_API_KEY}"

{"facet_counts":[{"counts":[{"count":4,"highlighted":"","value":"average"},{"count":2,"highlighted":"","value":"good"}],"field_name":"discountPercentage","sampled":false,"stats":{"avg":35.833333333333336,"max":70.0,"min":10.0,"sum":215.0,"total_values":2}}],"found":6,"hits":[],"out_of":6,"page":1,"request_params":{"collection_name":"product_variants","per_page":0,"q":"*"},"search_cutoff":false,"search_time_ms":0}{"facet_counts":[{"counts":[{"count":0,"highlighted":"","value":"good"},{"count":0,"highlighted":"","value":"average"}],"field_name":"discountPercentage","sampled":false,"stats":{"avg":35.833333333333336,"max":70.0,"min":10.0,"sum":215.0,"total_values":2}}],"found":3,"found_docs":6,"grouped_hits":[],"out_of":6,"page":1,"request_params":{"collection_name":"product_variants","per_page":0,"q":"*"},"search_cutoff":false,"search_time_ms":0}%
Note how stats is same but the facet_counts array is different in two results
k
@Vamshi Aruru This is a bug (or rather an oversight). Can you please create a Github issue. We will prioritize the fix.
v
k
Thank you.