Documentation Center

Examples of invalid recommendation samples

If you use the recommend parameter wrongly, you get a validation error.

id is specified, but all concepts elements have conceptIds specified

search(
  recommend: {
    id: "tcm:8_415"
    concepts: [
      {
        connectorId:"cocktails"
        conceptIds:["e-learning-poolparty-biz_cocktails_bab016bd-2fd5-4809-bfe7-3225d25f116d"]
      }
      {
        connectorId:"ingredients"
        conceptIds:["e-learning-poolparty-biz_cocktails_bab016bd-2fd5-5889-bfe7-3225dea4419c"]
        boostBy: 5
      }
    ]
  }
)

The sample above is invalid because each item in the concepts array has a conceptIds array, whose values override the concepts of the item identified by id. As a result, the id property is unnecessary, which makes the query invalid.

No id is specified, but some concepts elements have no conceptIds specified

search(
  recommend: {
    concepts: [
      {
        connectorId:"cocktails"
        conceptIds:["e-learning-poolparty-biz_cocktails_bab016bd-2fd5-4809-bfe7-3225d25f116d"]
      }
      {
        connectorId:"ingredients"
        boostBy: 5
      }
    ]
  }
)

The sample above is a counterpart to the previous sample: it's invalid because one item in the concepts array has no conceptIds child. In that case, the concepts should be taken from the item identified by an id property, but no such property is set. As a result, the query is invalid.

The same scheme is set twice in the concepts array

 search(
  recommend: {
    id: "tcm:8_415"
    concepts: [
      {
        connectorId:"cocktails"
        conceptIds:["e-learning-poolparty-biz_cocktails_bab016bd-2fd5-4809-bfe7-3225d25f116d"]
      }
      {
        connectorId:"ingredients"
        boostBy: 5
      }
      {
        connectorId:"ingredients"
        boostBy: 4
      }
    ]
  }
)

The fact that connectorId: "ingredients" occurs twice causes the query to be invalid. You may run into this error if you create a reusable query with a large concepts array, and accidentally add the same scheme twice.

boostBy has a negative value

search(
  recommend: {
    id: "tcm:8_415"
    concepts: [
      {
        connectorId:"cocktails"
        conceptIds:["e-learning-poolparty-biz_cocktails_bab016bd-2fd5-4809-bfe7-3225d25f116d"]
      }
      {
        connectorId:"ingredients"
        boostBy: -5
      }
    ]
  }
)

The boostBy property cannot have a negative value. This query is invalid.