Trouble with 'q' Parameter in Typesense query
TLDR ryosuke_shiomi was having trouble with a Typesense query involving the 'q' parameter. Kishore Nallan suggested a temporary workaround and proposed using the latest builds to fix the issue. The solution was under trial at the end of the thread.
Mar 11, 2022 (22 months ago)
ryosuke_shiomi
07:14 AMKishore Nallan
07:24 AMquery_by
clause requires a list of fields, but I see that in your query you have -${userId1} -${userId2} -${userId3} …
which is strange.ryosuke_shiomi
07:29 AMIn exactly,
const searchParams = {
q: "-${userId1} -${userId2} -${userId3} …",
query_by: "userId",
filter_by: "favoriteGame: APEX"
}
Kishore Nallan
07:34 AMuserId
field? Is it an array of user IDs or just a single user ID?ryosuke_shiomi
07:38 AMschema is it (it is not all params because the app is not mine, is my office’s.)
collection 'users'
userId: string
favGame: string
createdAt: Date(int)
Kishore Nallan
07:40 AMryosuke_shiomi
07:42 AMKishore Nallan
07:43 AMq: "*",
filter_by: "favoriteGame: APEX && userId:!= [${userId1}, ${userId2}, ${userId3}]"
ryosuke_shiomi
07:44 AMAfter I try it, i would report the result.
Kishore Nallan
07:59 AMryosuke_shiomi
08:13 AMI tried the answer, but returned error.
what is the ‘facet field’?
results: [
{
code: 400,
error: 'To perform exclude filtering, filter field `userId` must be a facet field.'
}
]
Kishore Nallan
08:16 AMuserId
field need to have facet: true
enabled in the schema for negation. You don't need this if the latest RC builds work.ryosuke_shiomi
08:16 AMso I will try to use it.
Kishore Nallan
08:26 AMq
field, if you use the 0.23 RC builds, the bug you faced earlier won't be there.ryosuke_shiomi
08:30 AMso, please give me the information about how to use 0.23.
Kishore Nallan
08:41 AMryosuke_shiomi
11:59 AMKishore Nallan
12:14 PMTypesense
Indexed 3015 threads (79% resolved)
Similar Threads
Fixing Multiple Document Retrieval in Typesense
Phil needed an efficient way to retrieve multiple documents by id. Kishore Nallan proposed a solution available in a pre-release build. After some bug fixing regarding id matching by Jason and Kishore Nallan, Phil successfully tested the solution.
Typesense Bug Fix with `canceled_at` Field and Upgrade Concerns
Mateo reported an issue regarding the treatment of an optional field by Typesense which was confirmed a bug by Jason. After trying an upgrade, an error arose. Jason explained the bug was due to a recent change and proceeded to downgrade their version. Future upgrade protocols were discussed.
Querying with Typesense-Js and Handling Null Values
michtio was querying using typesense-js and receiving fewer results than expected. Kishore Nallan suggested using different query parameters. Further discussion led to the handling of 'null' values and filtering syntax in the search queries. The thread ended with Jason offering migration support from Algolia to Typesense.
Querying with Not-in in Typesense
Masahiro inquired about using not-in queries in Typesense. Kishore Nallan explained how to conduct such queries by using the "-" operator in the query string, and assisted Masahiro with issues stemming from a high number of exclusion tokens. The problem was eventually resolved by switching to the `multi_search` endpoint.
Resolving Issues with Infix and Prefix in Query Searches
Daren struggled with searches missing values in production. Jason and Kishore Nallan offered insights and created new features to help solve the problem, which was then tested and deployed by Daren.