How to query with pinned records using java client (without creating rule)

Dear Team,

For merchandising, we are not using Algolia native merchandising tool. For this purpose, we have created a new tool.

Since we have no rules created in Algolia dashboard, I was wondering how can we use java client library to create a query which supports all rules feature such as Pin Items, Hide Items, Boost categories, Bury categories, filter results, order Facets.

For example,
In algolia index, we have hundred records (R1, R2…R100).
We want to create a query using client api in which we can mention the Pin Items (R10 at position 1, R6 at position 3, R05 at position 5).

Is it possible without creating rules? And how?

Thanks,
Shivesh

Hi Shivesh,

If you want the re-ranking/pinning to occur within the Algolia service, you’ll need rules. We discuss the three different ways to build merchandising rules (visual editor, manual, and API) here in the docs

You can use any of these methods to construct rules to pin items, re-rank, etc. for your index within the service. The re-ranked/pinned items will appear in the correct position in the hits array for the response.

Without rules we won’t be able to inject the pinned items prior to returning the hits array to the client. But there’s nothing to stop you from injecting “pinned” items yourself into the hits array on the client side before displaying them.

Another approach would be to use your merchandizing tool to inject a score attribute into your records you could use to change the sort order, but that would not guarantee records would be pinned in a specific position.

Quick follow-up --today I discovered one of my colleagues has written a guide around content injection on the client side that may help you with this: