Querying String Arrays with Prefix=false and Typesense
TLDR Roman needed assistance with querying string arrays using prefix=false in Typesense. Kishore Nallan clarified how searching array elements works and advised using a plain string.
1
Feb 21, 2023 (10 months ago)
Roman
07:50 AMprefix=false
usage.Roman
07:51 AM•
query_by
has a single string[]
field• no additional params except
prefix=false
are set, we want to find documents that have both “react” (or its synonym) and “python” (or its synonyms) in string[]
field that is being queried, we don’t need prefixed search for any of these terms• there are synonyms defined for “react”: “reactjs,REACT.JS,reactJS,React js,React,React.JS,react js,react,react-jsx,react.js,Reactjs,React.Js,React.js,ReactJS,React JS”
• no synonyms for word “python” are set
Roman
07:51 AMq
, we’d expect Typesense to find the same amount of records for both “react python” and “python react”.Roman
07:55 AMprefix=false
makes result somewhat the same, but I think we want to keep it because we don’t want q
like “python java” to result in documents containing “javascript”Roman
08:00 AMKishore Nallan
08:10 AMreact python
will NOT match against a field value of ["react", "python"]
because they are considered as separate elements.1
Kishore Nallan
08:12 AMfilter_by=tags:[react, python]
Roman
11:19 AMFeb 22, 2023 (10 months ago)
Roman
04:15 PM> we still expect both tokens in the query to appear within a single array element
I don’t think so? I mean the screenshots above show how Typesense successfully queries against a string array field, it’s just the amount of results changes depending on whether “react python” or “python react” is set to
q
Is there a way to tell Typesense that the order of words doesn’t matter? And keep
prefix=false
so “java” matches only to “java” and not “javascript”Kishore Nallan
04:22 PMRoman
04:28 PMRoman
04:31 PMtags: string[]
containing all words present in q
(or their synonyms)?Feb 24, 2023 (9 months ago)
Roman
12:06 PMKishore Nallan
12:08 PMfoo bar
will NOT match [foo, bar]
array.Kishore Nallan
12:08 PMTypesense
Indexed 3011 threads (79% resolved)
Similar Threads
Typesense Search Query
Mischa was having issues with a Typesense search query and Jason suggested setting the prefix parameter to false.
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.
Querying and Indexing Multiple Elements Issues
Krish queried fields with multiple elements, which Kishore Nallan suggested checking `drop_tokens_threshold`. Krish wished to force OR mode for token, but Kishore Nallan admitted the feature was missing. Krish was able to resolve the issue with url encoding.
Resolving Typesense Search Issues
Conversation started by Maximilian about Typesense search behavior led to Users Kishore Nallan and Mike discussing and suggesting workaround, with Kishore Nallan promising an official solution soon. No final confirmation of resolution provided.
Solving Typesense Cloud Interface Issue in Python
Orion had an issue querying from Python in the Typesense Cloud interface. Kishore Nallan identified the problem within the array declaration. They then discussed improving error messages and Orion offered to make a PR.