Hi all, trying to make a simple recommendation que...
# community-help
a
Hi all, trying to make a simple recommendation query against a “tags” string[] to match against user selected tags, but having some trouble. I would expect the the results to be ordered with documents containing the most matching tags appearing first, but the documents don’t even always get returned, and if they do they are not sorted correctly. Also, the order of the tags in the query greatly affects the results. For example:
q='tradition_daoism tradition_buddhism topic_freedom topic_bliss style_body style_meditation'&query_by=tags&prefix=false
returns documents with a single matching tag in the array, and then in the 15th spot will return documents that match 2-3 tags, and it doesn’t return all documents with multiple matching tags. Also changing the query string order of the tags will affect what documents get returned and in which order. Have also tried using
filter_by=tags:[tradition_daoism, etc.…]
, but that doesn’t sort by number of matching tags either. Feels like I’m missing something obvious, but can’t seem to make any progress, any tips are appreciated.
j
@Adrian
I would expect the the results to be ordered with documents containing the most matching tags appearing first,
We don’t do this within a string array, only a regular string field. Could you change this field into a string and separate entries by space and try with the
q
parameter?
a
Ok got it…I’ll try and add an extra field that flattens the array into a string and see how that works. Thanks for the response! Seems like it might a useful feature for string arrays, any plans for something that might achieve a similar functionality?
j
We don’t have plans at the moment, but could you open a Github issue for this, describing your use-case, so we can track demand?
👍 1
a
@Jason Bosco circling back here, I tried making it a space delimited string, and using “q” but still seeing odd results. Seems like the text match score is the same for all results, irrespective of how many matching tokens there are. Feels like a bug, or maybe related to having a lot of tokens in “q” ?
/collections/articles/documents/search?q=tradition_buddhism tradition_daoism style_body style_meditation topic_bliss topic_freedom&query_by=tagsString&include_fields=tagsString,id&highlight_fields=none&highlight_full_fields=none&prefix=false&per_page=100
Gives this output, as an example note how the penultimate result has 3 matching tokens, yet has the same textmatch scores. (ps. this is on Typesense cloud v0.24)