How to perform Deduplication search

I have a doubt regarding deduplication. I have a set of data

[
  {
    "shopId": 1,
    "tags": [
      "shirt",
      "textile"
    ],
    "status": "active"
  },
  {
    "shopId": 1,
    "tags": [
      "pants"
    ],
    "status": "active"
  },
  {
    "shopId": 1,
    "tags": [
      "socks"
    ],
    "status": "deleted"
  }
]

I have enabled the distinct feature with shopId attribute. I need help on the following.

  1. If i searched one of the tags. Eg: Textile, pants The result should appear and should be unique to shopId
  2. It should filter out the deleted status item. it is sorted by created date and for say if the item sock was the most recent data and its status is deleted. The data should show the next recent data which is pants

You should be able to do all of this, provided you set shopId as an attributeForDistinct and distinct: true in your index configuration. Then, make sure you set distinct:true in you search.

More details: Item variations | Algolia

You can accomplish #2 by setting a filter for "status": "active" in either you configuration or query.

Interesting. Do you mind sharing your index configuration and your query? Also have you considered using the special _tags attribute for this?