Sort element with property: true to the top, but only one out of many

Hi @Florian_Walther,

I want to move exactly one of these sponsored entries to the top of the search results, but keep natural ordering up for the remaining ones ( no matter if sponsored or not ).

From what it sounds like here, it doesn’t really sound like a sort per se. It sounds like you are wanting to “re-arrange” the result set. Is this correct?

In saying so, could you provide the following details so I can try work out a possible method to see if the desired output can be achieved?:

  1. MongoDB Version.
  2. Search index details.
  3. Full $search stage details
  4. 4-5 sample documents.
  5. The expected / desired output.
  6. Output from the $search stage whilst highlighting which document where sponsored:true you wish to have moved to the top (e.g. if there are multiple documents in the result set with sponsored:true , which one should go to the top? The highest scoring, or a random one)

Please redact any personal or sensitive information before posting it here

Regards,
Jason

3 Likes