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

Recommendation API Profile Specific Parameters #1130

Closed
korgon opened this issue Aug 8, 2024 · 4 comments · Fixed by #1143
Closed

Recommendation API Profile Specific Parameters #1130

korgon opened this issue Aug 8, 2024 · 4 comments · Fixed by #1143
Assignees
Labels
type: feature New functionality

Comments

@korgon
Copy link
Contributor

korgon commented Aug 8, 2024

The Recommendation API has undergone some changes that open up the ability to specify profile specific parameters when using the POST request.

We will be removing the GET request to this API altogether due to complications in transformation of the requests formats.

API Details

Profile specific parameters: limit, categories, brands, dedupe, filters, searchTerm

Example POST request (apparently parameter names are not case sensitive, because we have never used capitalized params):

{
    "Products": ["14503"],
    "BlockedItems": ["7143"],
    "Cart": ["11444", "16741"],
    "LastViewed": ["11384", "330597"],
    "WithRecInfo": true,
    "Profiles":[
        {
            "tag":"default-category-trending",
            "categories":["479516786979"],
            "limit": 5
        },
        {
            "tag":"default-similar",
            "limit": 15
        },
        {
            "tag":"default-cross-sell"
        },
        {
            "tag":"default-cart-cross-sell",
            "dedupe": false
        }
    ]
}

Snap Integration

Of the profile specific parameters, only dedupe and searchTerm are new.

The new dedupe parameter allows for profiles to NOT dedupe if they request false for this param - this allows us to no longer need to "unbatch" profiles to prevent de-duplication. Because of backwards compatibility we will have to keep the "batched" functionality, but will add dedupe as an option that can be set in the script context (or via controller configuration).

The new searchTerm parameter allows for adding a "query" to the request to further filter out the result set.

Considering how existing batched requests work we may have to find a clever way to move to this new API without disturbing existing implementations. For example, as site may have a batched request for 'similar' and 'brand' profiles, the brand profile currently may be the only one that has a brand script context option set, but the batched request will consider brand for both profiles. If we move completely over to using the new API we might cause a difference in the result set that is expected.

@korgon korgon added the type: feature New functionality label Aug 8, 2024
@chrisFrazier77 chrisFrazier77 self-assigned this Aug 9, 2024
@neil4tell neil4tell changed the title Recommendation API Profile Specific Paramters Recommendation API Profile Specific Parameters Aug 15, 2024
@neil4tell
Copy link

I wouldn't worry too much about the differences in the result set when you transition the brands and categories to be profile-specific. The current global setting will have very little affect on similar and cross sell recommendations. In extreme edge cases where there are no good similar or cross-sell results for an item, the existence of a brand or category parameter will default to show brand-trending or category-trending results instead of site-wide trending. That should not be affecting a significant number of the pages showing those results, because the vast majority of pages should have good crowd and genomic recommendations and not have to resort to trending items. Those that do should be fine showing site-wide trending instead.

@korgon
Copy link
Contributor Author

korgon commented Aug 20, 2024

This is turning out to be not as straightforward as initially thought - need to determine best path forward.

Option 1:

New script block interface, identified by a new type:

<script type="searchspring/recommend/profile" profile="similar">
  globals = {};
  profile = {};
</script>

Requires maintaining two script integration interfaces and multiple API types.

Option 2:

Lift all recommendation context options (current and new) to be global (except profile specific contained in a new "profile" section).

<script type="searchspring/recommend" profile="similar">
  products = ['sku1']; // global
  options = {
    categories: ['shoes'], // global
  };
  profile = { // profile specific
    categories: [], // empty to NOT use global value
  };  
</script>

Would need to empty out parameters that have been lifted globally (as needed).

API would need to:

  • support all parameters globally (dedupe excluded)
  • support all parameters per profile
  • override global parameters with profile specific parameters

Option 3:

Each script block ONLY provides profile specific options (no globals) - we could add support for defining globals. Would likely cause many breaking changes to existing integrations.

<script type="searchspring/recommend" profile="similar">
  products = ['sku1']; // profile specific
  options = {
    categories: ['shoes'], // profile specific
    search: 'red',
  };
</script>

API would need to:

  • support all parameters per profile

@korgon
Copy link
Contributor Author

korgon commented Aug 21, 2024

Option 1:

<div class="above-content" style="min-height: 20px"></div>
<!-- other content-->
<div class="below-content"></div>


<script type="searchspring/recommendations">
  globals = {};
  profiles = [
    {
      profile: 'bundle',
      target: '.above-content',
      parameters: {
        dedupe: true,
        categories: [],
      },
    },
    {
      profile: 'similar',
      target: '.below-content',
      parameters: {
        dedupe: false,
        categories: [],
      }
    }
  ];
</script>

@korgon
Copy link
Contributor Author

korgon commented Sep 12, 2024

Merged into develop. Part of 0.60.0 release.

@korgon korgon closed this as completed Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants