JSON-LD Filter on metadata

JSON-LD Filter on metadata

The parameter ldjsonfilter

<div class="rek-prediction" data-ldjsonfilter.keywords="summer"></div>

Or if prediction is made via Javascript:

options.params['ldjsonfilter.keywords'] = 'summer';

Look at the example below to see how you filter out these pages when doing recommendations.

Complete example where additionalType are added and filtered on:

In order for a page to be filtered, you can add this to an ld+json object.

<script type="application/ld+json" data-rekai>
  {
    "@context": "https://schema.org",
    "@type": "Article",
    "additionalType": "Podcast"
  }
</script>

It is then possible to filter on this value either in the html div:

<div class="rek-prediction" data-ldjsonfilter.additionalType="Podcast"></div>

Or via javascript:

<script>
  $( document ).ready(function() {
    function printPredictions(data) {
      console.log(data);
    }
 
    var options = {
      params: {
        subtree: '/news/',
      }
    };
    // Filter on this keyword
    options.params['ldjsonfilter.additionalType'] = 'Podcast';
 
    window.__rekai.predict(options, printPredictions);
  });
</script>

Comma separate the filter

If you enter several choices separated by a comma, it is enough for one of them to be correct for the page to be sent back as a recommendation.

<div class="rek-prediction" data-ldjsonfilter.keywords="Podcast,Movie"></div>

Use category to filter products or pages

If a website has a large number of products that are divided into several categories, these can be filtered using "category". Rek.ai reads "category" from your json ld object, and then lets you filter on the value using data-category. Categories are divided into subgroups in the same way that Google does in its functions. Namely by adding ">" to the string.

Example: "Food>Breakfast>Eggs"

You can then filter on which of these levels you want to get all products within the category.

Example: data-filtercategory="Food>Breakfast"