Filter "UNIQUE" => Distinct on a field. For search and facet

Bonjour,

I have several records that have different ids but have a field (docga_id) that has the same value.
I’m looking for a solution so that the search only finds one of these contents.

My search also finds records that do not have this field at all.

Exemple :

records :

[
  {
    "objectID": 1,
    "docga_id": 12345
  },
  {
    "objectID": 2,
    "docga_id": 12345
  },
  {
    "objectID": 3,
    "docga_id": 54321
  },
  {
    "objectID": 4,
  },
]

I would like my search to find 1, 3 and 4 and not 2 because 1 and 2 have the same docga_id

How to do it ?

You can use the distinct and attributeForDistinct parameters to only show the most relevant record(s) for the dog_ga_id attribute.

You can read more about it here:

image

it works for the search result. But it is not taken into account in the counting of the facet elements.

[
  {
    "objectID": 1,
    "docga_id": 12345,
    "tab": document
  },
  {
    "objectID": 2,
    "docga_id": 12345,
    "tab": document
  },
  {
    "objectID": 3,
    "docga_id": 54321,
    "tab": document
  },
  {
    "objectID": 4,
    "tab": document
  },
  {
    "objectID": 5,
    "tab": product
  },
]

My Query :
image

A want

{
  "facets": {
     "tab": {
         "document: 3,
         "product": 1
}}}

I have

{
  "facets": {
     "tab": {
         "document: 4,
         "product": 1
}}}