Skip to content

Facet Distribution count jumping around between distinct value and non-distinct value #1354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pipech opened this issue Jan 7, 2025 · 2 comments
Labels
help wanted Extra attention is needed instant-meilisearch needs investigation Needs to take more time to understand the issue

Comments

@pipech
Copy link

pipech commented Jan 7, 2025

Not sure if this the right place for this bug, there are many layer of abstraction on this component.

Context
I'm building a e-commerce site, the data I sent to Meilisearch is on SKUs level then I set productId as distinct value on Meilisearch.

The actual total product count is 18, and 105 for total skus.

Description / Current behavior
Facet Distribution count jumping around between count of Product and SKUs on select.
Notice how Roast Level: Medium count change from 7 to 41 when I select Roast Level: Dark.

Expected behavior
I can set Facet Distribution count to count of the productId which was set as distinct value.
From this example I would like Roast Level: Medium count to remain 6 on selection of Roast Level: Dark.

Screenshots

product_media_ordering

Network Request

Response (I cut some irrelevant part off.)

{
  "results": [
      {
          "indexUid": "products",
          "hits": [
              "..."
          ],
          "query": "",
          "processingTimeMs": 9,
          "limit": 21,
          "offset": 0,
          "estimatedTotalHits": 6,
          "facetDistribution": {
              "categoryHierarchy.lvl0": {
                  "coffees": 6
              },
              "categoryHierarchy.lvl1": {
                  "coffees > roasted-beans": 6
              },
              "productAttributeDict.Roast Level": {
                  "Medium": 6
              },
              "productAttributeDict.Type": {
                  "Blends": 1,
                  "Single Origin": 5
              }
          },
          "facetStats": {
              "variantSku.promoPrice": {
                  "min": 359.0,
                  "max": 660.0
              },
              "variantSku.variantDisplay.Bag Size.meta.unitData.value": {
                  "min": 200.0,
                  "max": 340.0
              }
          }
      },
      {
          "indexUid": "products",
          "hits": [
              "..."
          ],
          "query": "",
          "processingTimeMs": 3,
          "limit": 1,
          "offset": 0,
          "estimatedTotalHits": 41,
          "facetDistribution": {
              "categoryHierarchy.lvl0": {
                  "coffees": 41
              },
              "categoryHierarchy.lvl1": {
                  "coffees > roasted-beans": 41
              }
          },
          "facetStats": {}
      },
      {
          "indexUid": "products",
          "hits": [
              "..."
          ],
          "query": "",
          "processingTimeMs": 2,
          "limit": 1,
          "offset": 0,
          "estimatedTotalHits": 105,
          "facetDistribution": {
              "productAttributeDict.Roast Level": {
                  "Dark": 30,
                  "Light": 18,
                  "Light-Medium": 16,
                  "Medium": 41
              }
          },
          "facetStats": {}
      },
      {
          "indexUid": "products",
          "hits": [
              "..."
          ],
          "query": "",
          "processingTimeMs": 2,
          "limit": 1,
          "offset": 0,
          "estimatedTotalHits": 41,
          "facetDistribution": {
              "categoryHierarchy.lvl0": {
                  "coffees": 41
              }
          },
          "facetStats": {}
      }
  ]
}

Request

{
  "queries": [
      {
          "indexUid": "products",
          "q": "",
          "facets": [
              "categoryHierarchy.lvl0",
              "categoryHierarchy.lvl1",
              "categoryHierarchy.lvl2",
              "productAttributeDict.Coffee Altitude",
              "productAttributeDict.Coffee Origin",
              "productAttributeDict.Coffee Process",
              "productAttributeDict.Coffee Species",
              "productAttributeDict.Coffee Variety",
              "productAttributeDict.Roast Level",
              "productAttributeDict.Taste Notes (SCA)",
              "productAttributeDict.Type",
              "shopDetail.shopSlug",
              "variantSku.promoPrice",
              "variantSku.variantDisplay.Bag Size.meta.unitData.value",
              "variantSku.variantDisplay.Grind Preference.meta.booleanText.value"
          ],
          "filter": [
              [
                  "\"productAttributeDict.Roast Level\"=\"Medium\""
              ],
              [
                  "\"categoryHierarchy.lvl1\"=\"coffees > roasted-beans\""
              ]
          ],
          "attributesToHighlight": [
              "*"
          ],
          "highlightPreTag": "__ais-highlight__",
          "highlightPostTag": "__/ais-highlight__",
          "limit": 21,
          "offset": 0,
          "distinct": "productId"
      },
      {
          "indexUid": "products",
          "q": "",
          "facets": [
              "categoryHierarchy.lvl0",
              "categoryHierarchy.lvl1"
          ],
          "filter": [
              [
                  "\"productAttributeDict.Roast Level\"=\"Medium\""
              ],
              [
                  "\"categoryHierarchy.lvl0\"=\"coffees\""
              ]
          ],
          "attributesToHighlight": [
              "*"
          ],
          "highlightPreTag": "__ais-highlight__",
          "highlightPostTag": "__/ais-highlight__",
          "limit": 1,
          "offset": 0,
          "distinct": "productId"
      },
      {
          "indexUid": "products",
          "q": "",
          "facets": [
              "productAttributeDict.Roast Level"
          ],
          "filter": [
              [
                  "\"categoryHierarchy.lvl1\"=\"coffees > roasted-beans\""
              ]
          ],
          "attributesToHighlight": [
              "*"
          ],
          "highlightPreTag": "__ais-highlight__",
          "highlightPostTag": "__/ais-highlight__",
          "limit": 1,
          "offset": 0,
          "distinct": "productId"
      },
      {
          "indexUid": "products",
          "q": "",
          "facets": [
              "categoryHierarchy.lvl0"
          ],
          "filter": [
              [
                  "\"productAttributeDict.Roast Level\"=\"Medium\""
              ]
          ],
          "attributesToHighlight": [
              "*"
          ],
          "highlightPreTag": "__ais-highlight__",
          "highlightPostTag": "__/ais-highlight__",
          "limit": 1,
          "offset": 0,
          "distinct": "productId"
      }
  ]
}

Environment

  • "@meilisearch/instant-meilisearch": "0.23.0"
  • "instantsearch.js": "4.75.6"
  • "meilisearch": "^0.47.0"
  • "react-instantsearch": "^7.13.9"
  • "react-instantsearch-nextjs": "^0.3.20"

Please let me know if you need any further information.

@Strift Strift added help wanted Extra attention is needed instant-meilisearch needs investigation Needs to take more time to understand the issue labels Jan 8, 2025
@Strift
Copy link
Collaborator

Strift commented Jan 8, 2025

Thanks for opening this issue. This rings a bell, but I haven't looked at facets for a while. I need to investigate whether or not it's related to the behavior mentioned in this discussion.

@pipech
Copy link
Author

pipech commented Jan 13, 2025

Switch to use Algolia as source, everything seems to works perfectly with afterdistinct settings.

So the problems seems to be somewhere on @meilisearch/instant-meilisearch or meilisearch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed instant-meilisearch needs investigation Needs to take more time to understand the issue
Projects
None yet
Development

No branches or pull requests

2 participants