Skip to content
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

Compute "dynamic" set of attribute histogram for references #8

Open
1 task
novoj opened this issue Feb 24, 2023 · 0 comments
Open
1 task

Compute "dynamic" set of attribute histogram for references #8

novoj opened this issue Feb 24, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@novoj
Copy link
Collaborator

novoj commented Feb 24, 2023

During discussion with Next.JS team (namely Jakub Ruffer), new idea sprung up. In current situation is up to them to maintain list of filterable parameters, cache it and ask actively for attributeHistogram computation. This requires quite a complex logic in the middleware and also caching (which bring a lot of additional problems). Jakub came with following idea - if he could ask for all "referenceHistograms" and specify a filterBy constraint which references:

{
  queryProduct(
    filterBy: {
      attributeStatusEquals: "ACTIVE"
    }
  ) {
    extraResults {
      facetSummary {
        parameterValues(
          filterGroupBy: {
            attributeIsVisibleInFilterEquals: true          
          }
          orderGroupBy: {
            attributeOrderNatural: ASC
          }
        ) {
          count
          groupEntity {
            primaryKey
            attributes {
              code
            }
          }
          facetStatistics @include(if: groupHaving(attributeInputWidgetTypeEquals("CHECKBOX"))) {
            requested
            count
            facetEntity {
              primaryKey
              attributes {
                code
              }
            }
          }
          histogramStatistics @include(if: groupHaving(attributeInputWidgetTypeEquals("INTERVAL"))) {
            width {
              min
              max
              overallCount
              buckets(
                requestedCount: 20
                behavior: OPTIMIZED
              ) {
                threshold
                occurrences
                requested
              }
              facetEntity {
                primaryKey
                attributes {
                  code                
                }
              }
            }
          }
        }
      }
    }
  }
}

and evitaDB would compute "dynamic" count of histograms for target attributes based on reference relevancy and grouped by ReferenceContract#group.

This approach has multiple benefits:

  1. we can mix checkbox and interval types inside single "facetSummary"
  2. this allows us to filter and order their groups in a single declaration
  3. we calculate different output depending on a attribute defined on the group entity or facet entity itself (i.e. conditionally)
  4. we could also retrieve different facet entity data long with the returned statistics, in case of histogram only boundary entities data can be provided because all intermediary thresholds are only virtual ones

Proposed solution relates also to: #474

  • we need to remove temporary extension to the GraphQL API histograms allowing to retrieve histograms by names used in variable argument
@novoj novoj added the enhancement New feature or request label Feb 24, 2023
@novoj novoj added this to the Alpha milestone Feb 24, 2023
novoj added a commit that referenced this issue Apr 15, 2024
ci: attempt to deploy image per MAJOR version #8
@novoj novoj modified the milestones: Alpha, Beta Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants