Collection

Overview

Collection is the heart of an application. It defines schema, aggregations, sorting and this generates application. Fortunately you don't need to know how to create collection. It is created out of the box in installation process and in later stage you can manage that by web interface in administration panel.

Movies collection example

The example is long but fortunately you don't need to worry about that. If you have JSON with items then it will be auto-generated.

{
  "name": "movies",
  "aggregations": {
    "director": {
      "type": "terms",
      "size": 15,
      "conjunction": true,
      "field": "director",
      "title": "director"
    },
    "year": {
      "type": "range",
      "field": "year",
      "title": "year",
      "ranges": [
        {
          "name": "1971 - 1978",
          "lte": 1978
        },
        {
          "name": "1978 - 1985",
          "lte": 1985,
          "gte": 1978
        },
        {
          "name": "1985 - 1992",
          "lte": 1992,
          "gte": 1985
        },
        {
          "name": "1992 - 1999",
          "lte": 1999,
          "gte": 1992
        },
        {
          "name": "1999 - 2010",
          "gte": 1999
        }
      ]
    },
    "tags": {
      "type": "terms",
      "size": 15,
      "conjunction": true,
      "field": "tags",
      "title": "tags"
    },
    "actors": {
      "type": "terms",
      "size": 15,
      "conjunction": true,
      "field": "actors",
      "title": "actors"
    }
  },
  "sortings": {
    "name": {
      "title": "name",
      "type": "normal",
      "order": "desc",
      "field": "name"
    },
    "year": {
      "title": "year",
      "type": "normal",
      "order": "desc",
      "field": "year"
    }
  },
  "schema": {
    "name": {
      "type": "string",
      "store": true
    },
    "director": {
      "type": "string",
      "index": "not_analyzed",
      "store": true
    },
    "rating": {
      "type": "float",
      "store": true
    },
    "votes": {
      "type": "integer",
      "store": true
    },
    "year": {
      "type": "integer",
      "store": true
    },
    "image": {
      "type": "string",
      "display": "image"
    },
    "description": {
      "type": "string",
      "store": true
    },
    "tags": {
      "type": "string",
      "display": "array",
      "index": "not_analyzed",
      "store": true
    },
    "actors": {
      "type": "string",
      "display": "array",
      "index": "not_analyzed",
      "store": true
    },
    "permalink": {
      "type": "string",
      "index": "not_analyzed",
      "store": true
    }
  }
}

Managing collection

In pure ItemsAPI the whole configuration is managed by JSON file, in MongoDB directly or by API. In starter it is simplier because there is administration panel.

Managing schema from admin panel
Managing aggregations from admin panel
Managing sortings from admin panel
Was this page helpful ?