Taxonomy Suggestions

Taxonomy Suggestions

In order to use the taxonomySuggest query you need to set up at least one content type as a taxonomy and add relationships from your other types to it. For example in the Shape Books pattern we have a book content type which is organized with a genre taxonomy.

query {
  taxonomySuggest(terms: "fan" contentTypeNames: ["book"]) {
    items {
      _id
      _contentTypeName
      text
    }
  }
}

This query looks for taxonomy items related to book which match "fan".

{
  "data": {
    "taxonomySuggest": {
      "items": [
        {
          "_id": "02a52a5a-aea1-4aed-9a46-799c14354a71",
          "_contentTypeName": "genre",
          "text": "Fantasy"
        }
      ]
    }
  }
}

In this example we found the genre "Fantasy". We can use this in a subsequent list query by using the exact relationship field genre or _references which allows us to filter by all relationships.

{
  "filter": {
    "term": {
      "_references": "02a52a5a-aea1-4aed-9a46-799c14354a71" 
    }
  }
}

Join us

Interested in joining the team as coworker or investor?

contact@takeshape.com