#community-help

Issues with Typesense location entries and facet counts

TLDR Ed encountered issue with Typesense returning incorrect results and facet counts for location search. Jason and Kishore Nallan helped identify the problem and proposed a fix.

Powered by Struct AI

2

1

19
2mo
Solved
Join the chat
Aug 01, 2023 (2 months ago)
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
05:16 PM
if I search for a location that actually has 3 entries for Systemingenieur Systemmodellierung (m/w/d), it is working fine, only 3 are showed, but for locations that has 0 entries then 180 are shown
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:17 PM
This is due to the drop_tokens_threshold setting which defaults to 1
05:18
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
05:18 PM
thanks

1

05:21
Ed
05:21 PM
that worked!

1

05:28
Ed
05:28 PM
one more issue
I got 3 jobs with a location array, they are all in germany but in 3 different locations, so the facets show as 9 jobs
Image 1 for one more issue
I got 3 jobs with a location array, they are all in germany but in 3 different locations, so the facets show as 9 jobs
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:32 PM
Could you share the facet counts returned by the Typesense API?
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
05:34 PM
{
                    "counts": [
                        {
                            "count": 3,
                            "highlighted": "Hamburg,Hamburg",
                            "value": "Hamburg,Hamburg"
                        },
                        {
                            "count": 3,
                            "highlighted": "Emden,Lower Saxony",
                            "value": "Emden,Lower Saxony"
                        },
                        {
                            "count": 3,
                            "highlighted": "Kiel,Schleswig-Holstein",
                            "value": "Kiel,Schleswig-Holstein"
                        }
                    ],
                    "field_name": "data.locations.cityState",
                    "sampled": false,
                    "stats": {
                        "total_values": 3
                    }
                },
                {
                    "counts": [
                        {
                            "count": 3,
                            "highlighted": "Hamburg",
                            "value": "Hamburg"
                        },
                        {
                            "count": 3,
                            "highlighted": "Lower Saxony",
                            "value": "Lower Saxony"
                        },
                        {
                            "count": 3,
                            "highlighted": "Schleswig-Holstein",
                            "value": "Schleswig-Holstein"
                        }
                    ],
                    "field_name": "data.locations.state",
                    "sampled": false,
                    "stats": {
                        "total_values": 3
                    }
                },
                {
                    "counts": [
                        {
                            "count": 9,
                            "highlighted": "Germany",
                            "value": "Germany"
                        }
                    ],
                    "field_name": "data.locations.country",
                    "sampled": false,
                    "stats": {
                        "total_values": 1
                    }
                }
            ],
            "found": 3,
05:36
Ed
05:36 PM
here’s the actual locations array
 "locations": [
                                {
                                    "address": "Werftstr. 112 - 114 , 24143 Kiel",
                                    "city": "Kiel",
                                    "cityState": "Kiel,Schleswig-Holstein",
                                    "country": "Germany",
                                    "state": "Schleswig-Holstein",
                                    "stateShort": "SH",
                                    "zipCode": "24143"
                                },
                                {
                                    "address": "Hermann Blohm Str 3",
                                    "city": "Hamburg",
                                    "cityState": "Hamburg,Hamburg",
                                    "country": "Germany",
                                    "state": "Hamburg",
                                    "stateShort": "Hamburg",
                                    "zipCode": "20457"
                                },
                                {
                                    "address": "Zum Zungenkai",
                                    "city": "Emden",
                                    "cityState": "Emden,Lower Saxony",
                                    "country": "Germany",
                                    "state": "Lower Saxony",
                                    "stateShort": "NDS",
                                    "zipCode": "26725"
                                }
                            ],
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:20 PM
Hmm, could you copy-as-curl the network request sent to Typesense from the browser, remove your cluster ID and API key and paste it here?
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
07:38 PM
yes, one sec
07:41
Ed
07:41 PM
Jason
curl '' \
  -H 'authority: ' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'content-type: text/plain' \
  -H 'dnt: 1' \
  -H 'origin: ' \
  -H 'referer: ' \
  -H 'sec-ch-ua: "Chromium";v="115", "Not/A)Brand";v="99"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36' \
  --data-raw '{"searches":[{"collection":"tkag_en","q":"Systemingenieur Systemmodellierung","query_by":"data.title,content","drop_tokens_threshold":0,"filter_by":"","sort_by":"_text_match:desc,data.postingDate_timestamp:desc","page":1,"per_page":50,"facet_by":"data.businessUnit,data.category,data.company,data.contract,data.employmentType,data.entryLevel,data.jobField,data.language,data.remote,data.locations.cityState,data.locations.state,data.locations.country","max_facet_values":500,"include_fields":"data,_geoloc"}]}' \
  --compressed
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:52 PM
Thank you, will take a closer look and keep you posted
Aug 02, 2023 (2 months ago)
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
01:32 PM
thanks
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:47 PM
We’re working on a fix for this. Should be ready in an RC build in a few days or so
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
04:48 PM
thanks!

1

Aug 04, 2023 (2 months ago)
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
02:58 PM
Kishore Nallan ^
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
03:03 PM
Yes, this is available in 0.25.0.rc60 as well.
Ed
Photo of md5-120c789e9edae8b90bf59cf0e2612b66
Ed
03:18 PM
thanks