@here Hey guys we are using doing some R&D on ...
# community-help
s
@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
?
k
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
For pinned hits, see the
pinned_hits
argument description here: https://typesense.org/docs/0.21.0/api/documents.html#arguments
s
@Kishore Nallan thank you so much, itseems like pinned_hits are applied only on ID field?
k
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.
s
is there a possibility where i. can promote the doc using another field?
k
Can you give me an example?
You mean, use another field as the identifier for the document?
s
lets say i have this following doc
Copy code
{"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
k
Yes, so you have to use
102
as the identifier for p2. You can't use another field, like
type
.
s
oh , is there any other way to achieve this?
k
In your example, you have multiple
p2
items -- is that the intent?
s
so when i search for a
name
i want to pin p2 results on top followed by p1
k
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.
s
oh okay got it , thank you
👍 1