#community-help

Troubleshooting Typesense API Key Error and Creating Search Functionality

TLDR Bill reported a Typesense API error, which Jason explained as due to a bad key. Bill also sought input on a job portal search functionality, which Jason assisted with, emphasizing normalization of job titles and use of facet query outside of Typesense.

Powered by Struct AI

1

34
26mo
Solved
Join the chat
Nov 16, 2021 (26 months ago)
Bill
Photo of md5-be53735a2b0297bb542711c1d2ecea45
Bill
06:34 PM
Hello, we have installed typesense successfully but we receive the following in logs -> "Malformed scoped API key." We don't have create any Scoped API Key
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:35 PM
That error message is actually a misnomer and I think it shows up if any bad API key is used
06:36
Jason
06:36 PM
We need to fix it
Bill
Photo of md5-be53735a2b0297bb542711c1d2ecea45
Bill
06:36 PM
So can we leave it as it is? We use the same master key in all nodes
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:39 PM
Are there are any requests with a valid API key that are returning a 401?
Bill
Photo of md5-be53735a2b0297bb542711c1d2ecea45
Bill
06:40 PM
We don't receive any error and as we check the logs all nodes work as expected
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:41 PM
Then you should be good, it could be a random crawler making an API call to an authenticated endpoint getting a 401
Bill
Photo of md5-be53735a2b0297bb542711c1d2ecea45
Bill
06:42 PM
Maybe it has the first master key in cache on each node when installed? (Before we set the same Master in all nodes)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:45 PM
Hmmm, that shouldn't be the case... because the master key is not replicated to other nodes
Bill
Photo of md5-be53735a2b0297bb542711c1d2ecea45
Bill
06:47 PM
Okay, we will leave it as it is since we have no issue
06:51
Bill
06:51 PM
We are trying to create a search job portal with the search functionality of https://jooble.org/ . For example if you type on "What position are you looking for?" it returns results (autocomplete) with job professions. What's the best way to do this with Typesense? Storing the position title as facet and search via facet_query?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:04 PM
Bill You could directly search the "position_title" field in the jobs collection.
07:06
Jason
07:06 PM
Facet query is only for when you want to search for the facets of a particular search query like this
Bill
Photo of md5-be53735a2b0297bb542711c1d2ecea45
Bill
07:14 PM
Yes I tried that (with query search instead of facet query) but I receive the records of job ads separated (hits). For example, we have in dataset many job ads with position titles -> eg Java Developer, Java-Engineer, Java Developer/Frontend, Java Frontend Developer. When a user is typing for example "java" I want to return the job ad titles that match this term and group them (like jooble). Is this possible with typesense?
07:16
Bill
07:16 PM
To understand better what I mean, you could go to jooble -> https://jooble.org/ and type for example -> "chef"
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:18 PM
Yes, you can group by fields in typesense: https://typesense.org/docs/0.21.0/api/documents.html#group-by

However, I suspect that they have another field in each document that is the normalized job title, and they use that as the grouping key when showing results.

So each of Java Developer, Java-Engineer, Java Developer/Frontend, Java Frontend Developer, etc might have a field called "normalized_position_title" with a value of "Java Developer"
07:19
Jason
07:19 PM
Oh I see what you mean now - as to why you want to use facet_query. In this case, you're right since you want to only show unique facet values in the results, you'd want to use a facet_query
Bill
Photo of md5-be53735a2b0297bb542711c1d2ecea45
Bill
07:21 PM
So the best way to achieve this is using facet_query in position title and get the unique position name and count number, am I right?
07:23
Bill
07:23 PM
The issue with the facet_query is that if we have 2 job positons with title "Java Developer" and "Java Developer-Engineer" it will return 2 results not one ("Java Developer")
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:50 PM
You would have to do that normalization of job titles outside of Typesense
07:53
Jason
07:53 PM
Because theres no way for Typesense to know that the keywords “Java Developer” map to “ Java Software Engineer” for eg
Bill
Photo of md5-be53735a2b0297bb542711c1d2ecea45
Bill
07:57 PM
Could I achieve this with query search? For example user's typing "chef" and using search query to return ( - 1) "chef" -> check how many documents have the term chef in job title, 2- pastry chef - check how many documents has pastry chef as title) Is this possible with typesense?
07:58
Bill
07:58 PM
In other words, I need to type a term in autocomplete ("chef"), check how many documetns have this term ("chef") and return additional info for this term ("chef pastry", "executive chef" etc..)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:00 PM
Yeah if you just search for chef and group by job title, the found param in the response will give you total found and you’ll also see a grouped_hits response with one group for each job title.
Bill
Photo of md5-be53735a2b0297bb542711c1d2ecea45
Bill
08:03 PM
I tried that, I receive the total found but in group (which I want) I get only 3 hits that are the maximum
08:08
Bill
08:08 PM
in grouped_hits->0 (item)-> I need the total number of documents for this group_key
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:08 PM
You can control that with the group_limit param
Bill
Photo of md5-be53735a2b0297bb542711c1d2ecea45
Bill
08:10 PM
Can I set it to unlimited? I don't know the exact number of matches to limit them
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:11 PM
No unfortunately. You could set it to a high value
Bill
Photo of md5-be53735a2b0297bb542711c1d2ecea45
Bill
08:13 PM
Okay I set it to 99, so in results I can show 99+ counts found for each group. Is this type of search use more memory than normal? Because it's searching for 5 terms instead of a normal query
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:18 PM
The difference during search time should be negligible, because the in memory indices are constructed at indexing time
Bill
Photo of md5-be53735a2b0297bb542711c1d2ecea45
Bill
08:22 PM
Okay, it works perfect!! One little issue, how can I return exact results in query search? On searching term "pastry chef" I want only job ads with title "pastry chef" included not "excecutive chef etc". (Not in autocomplete, in normal search when user selected the autocomplete value (eg pastry chef)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:31 PM
You want to set drop_tokens_threshold: 0
Bill
Photo of md5-be53735a2b0297bb542711c1d2ecea45
Bill
09:26 PM
Perfect! Thank you very much for your time!

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3011 threads (79% resolved)

Join Our Community

Similar Threads

Understanding and Implementing Typesense Dart Library with Flutter

Alexandro sought help with the Typesense Dart library. Jason explained that the library is in progress, discussed utilizing other HTTP libraries, and provided detailed instructions on utilizing Typesense with Flutter. Alexandro provided feedback on the Typesense UI and expressed interest in creating a tutorial video.

10

82
32mo

Troubleshooting Typesense Setup and Understanding Facets and Keywords

Demitri encountered errors when exploring Typesense for the first time. Jason guided them through troubleshooting and discussed facets, keyword settings, and widget configurations. Helin shared a Python demo app and its source code to help Demitri with their project.

1

56
21mo
Solved

Resolve Facets and Sorting Issues with Typesense

Ethan needed assistance with getting all facet values and sorting results by date using Typesense. Jason provided guidance on how to use Typesense properties to accomplish these tasks, and resolved issues related to specific use-cases provided by Ethan and Rushil.

11

70
4mo
Solved

Phrase Search Relevancy and Weights Fix

Jan reported an issue with phrase search relevancy using Typesense Instantsearch Adapter. The problem occurred when searching phrases with double quotes. The team identified the issue to be related to weights and implemented a fix, improving the search results.

6

111
8mo
Solved

Utilizing Vector Search and Word Embeddings for Comprehensive Search in Typesense

Bill sought clarification on using vector search with multiple word embeddings in Typesense and using them instead of OpenAI's embedding. Kishore Nallan and Jason informed him that their development version 0.25 supports open source embedding models. They also resolved Bill's concerns regarding search performance, language support, and limitations in the search parameters.

11

225
4mo
Solved