#community-help

Implementing Result Pinning in Typesense Product

TLDR Sai questioned about implementing result pinning in Typesense for a product. Kishore Nallan provided several resources and explanations to assist, ultimately suggesting the use of 'sort_by' to promote groups of objects based on an attribute.

Powered by Struct AI

1

15
30mo
Solved
Join the chat
Jul 30, 2021 (30 months ago)
Sai
Photo of md5-6c1f32ee79d1166e54e3f17345b8d814
Sai
05:45 AM
@here Hey guys we are using doing some R&D on typesense for our product , can someone help me out how to implement Result Pinning ?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
05:47 AM
For result curation, you can use either the overrides feature or the pinned hits feature.

Overrides: https://typesense.org/docs/0.21.0/api/curation.html#curation
05:47
Kishore Nallan
05:47 AM
For pinned hits, see the pinned_hits argument description here: https://typesense.org/docs/0.21.0/api/documents.html#arguments
Sai
Photo of md5-6c1f32ee79d1166e54e3f17345b8d814
Sai
07:15 AM
Kishore Nallan thank you so much, itseems like pinned_hits are applied only on ID field?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:15 AM
Pinned hits are basically a list of documents that you want to show in a set of pre-determined positions. The documents are identified by their IDs.
Sai
Photo of md5-6c1f32ee79d1166e54e3f17345b8d814
Sai
07:18 AM
is there a possibility where i. can promote the doc using another field?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:19 AM
Can you give me an example?
07:19
Kishore Nallan
07:19 AM
You mean, use another field as the identifier for the document?
Sai
Photo of md5-6c1f32ee79d1166e54e3f17345b8d814
Sai
07:22 AM
lets say i have this following doc
{"id":100,"type":"p1","name":"xyz"},{"id":102,"type:"p2":"name":"abc"},
{"id":103,"type:"p1":"name":"abcd"}
{"id":104,"type:"p2":"name":"abcde"}
{"id":105,"type:"p2":"name":"abcdef"}

i want to pin p2 results first then p1
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:23 AM
Yes, so you have to use 102 as the identifier for p2. You can't use another field, like type .
Sai
Photo of md5-6c1f32ee79d1166e54e3f17345b8d814
Sai
07:24 AM
oh , is there any other way to achieve this?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:25 AM
In your example, you have multiple p2 items -- is that the intent?
Sai
Photo of md5-6c1f32ee79d1166e54e3f17345b8d814
Sai
07:26 AM
so when i search for a name i want to pin p2 results on top followed by p1
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:27 AM
You can achieve that by using sort_by if you identify p2 by numerical values (it will become some kind of weighting). There is no way to promote groups of objects based on an attribute using pinning or overrides.
Sai
Photo of md5-6c1f32ee79d1166e54e3f17345b8d814
Sai
07:29 AM
oh okay got it , thank you

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

Troubleshooting 'Contains' Match and Override Issues in Typesense

John sought assistance due to a seemingly faulty override in Typesense that failed to bring up a specific entry. Jason suggested troubleshooting steps, including trying a smaller record set and considering a server upgrade. A bug with 'contains' match appeared identified but not conclusively resolved.

1

40
20mo

Trouble in Implementing Deeply Nested Search

Anirudh is struggling to implement a two-level nested search. Jason asked for some specific examples to study the issue. Anirudh provided some material, realizing that adding top fields helped but might over-index. Jason then suggested reporting this issue on GitHub.

2

21
today

Resolving Typesense Result Issue in Document Collection Queries

Mike was encountering errors when searching for specific query in their Typesense document collection. Jason suggested it may be due to the `drop_tokens_threshold` setting. There was a misunderstanding but after further explanation from Jason, Mike understood and decided to continue the conversation via email.

1

19
21mo

Issues Sorting Multiple Fields with Sort_by in Typesense Query

Rishabh was having trouble sorting two fields separately with a single query. Jason explained that a secondary sorting will only occur if the first sort results in matching values. They clarified the functionality of sorting in various search engines.

3

34
34mo

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