Views

Views are rooted in the /v1/views/{org_label}/{project_label} collection and are used to index the selected resources into a bucket.

Each view…

  • belongs to a project identifier by the label {project_label}
  • inside an organization identifier by the label {org_label}
  • it is validated against the view schema.

Access to resources in the system depends on the access control list set for them. Depending on the access control list, a caller may need to prove its identity by means of an access token passed to the Authorization header (Authorization: Bearer {token}). Please visit Authentication to learn more about how to retrieve an access token.

Authorization notes

When modifying views, the caller must have views/write permissions on the current path of the project or the ancestor paths.

When querying views, the caller must have views/query permissions on the current path of the project or the ancestor paths.

When reading views, the caller must have resources/read permissions on the current path of the project or the ancestor paths.

View types

view defaults

There are several types of views, which relies on different technology to perform the indexing

SparqlView

This view creates a SPARQL namespace where it stores the selected resources inside the view project.

A default view gets automatically created when the project is created but other views can be created.

SparqlView payload

{
  "@id": "nxv:defaultSparqlIndex",
  "@type": [ "View", "SparqlView" ],
  "resourceSchemas": [ "{resourceSchema}", ...],
  "resourceTypes": [ "{resourceType}", ...],
  "resourceTag": "{tag}",
  "includeMetadata": {includeMetadata},
  "includeDeprecated": {includeDeprecated}
}

where…

  • {resourceSchema}: Iri - Selects only resources that are validated against the provided schema Iri. This field is optional.
  • {resourceType}: Iri - Selects only resources of the provided type Iri. This field is optional.
  • {tag}: String - Selects the resources with the provided tag. This field is optional.
  • {includeMetadata}: Boolean - If true, the resource’s nexus metadata (_constrainedBy, _deprecated, …) will be stored in the Sparql graph. Otherwise it won’t. The default value is false.
  • {includeDeprecated}: Boolean - If true, deprecated resourcess are also indexed. The default value is false.

ElasticSearchView

This view creates an ElasticSearch index where it stores the selected resources inside the view project.

A default view gets automatically created when the project is created but other views can be created.

ElasticSearchView payload

{
  "@id": "{someid}",
  "@type": [ "View", "ElasticSearchView"],
  "resourceSchemas": [ "{resourceSchema}", ...],
  "resourceTypes": [ "{resourceType}", ...],
  "resourceTag": "{tag}",
  "sourceAsText": {sourceAsText},
  "includeMetadata": {includeMetadata},
  "includeDeprecated": {includeDeprecated},
  "mapping": _elasticsearch mapping_
}

where…

  • {resourceSchema}: Iri - Selects only resources that are validated against the provided schema Iri. This field is optional.
  • {resourceType}: Iri - Select only resources of the provided type Iri. This field is optional.
  • {tag}: String - Selects only resources with the provided tag. This field is optional.
  • _elasticsearch mapping_: Json object - Defines the value types for the Json keys, as stated at the ElasticSearch mapping documentation.
  • {sourceAsText}: Boolean - If true, the resource’s payload will be stored in the ElasticSearch document as a single escaped string value of the key _original_source. If false, the resource’s payload will be stored normally in the ElasticSearch document. The default value is false.
  • {includeMetadata}: Boolean - If true, the resource’s nexus metadata (_constrainedBy, _deprecated, …) will be stored in the ElasticSearch document. Otherwise it won’t. The default value is false.
  • {includeDeprecated}: Boolean - If true, deprecated resourcess are also indexed. The default value is false.
  • {someid}: Iri - The @id value for this view.

AggregateElasticSearchView

This view is an aggregate of ElasticSearchViews. The view itself does not create any index, but it references the already existing indices of the linked ElasticSearchViews.

When performing queries on the _search endpoint, this view will make use of the multi-index query capabilities of ElasticSearch in order to select the indices of every view present on this aggregate view.

If the caller does not have the permission views/query on all the projects defined on the aggregated view, only a subset ofindices (or none) will be selected, respecting the defined permissions.

Aggregate ElasticSearchView

AggregateElasticSearchView payload

{
  "@id": "{someid}",
  "@type": [ "View", "AggregateElasticSearchView"],
  "views": [ 
    {
        "project": "{project}",
        "viewId": "{viewId}"
    },
    ...
  ]
}

where…

  • {project}: String - The project, defined as {org_label}/{project_label}, where the {viewId} is located.
  • {viewId}: Iri - The view @id value to be aggregated.

AggregateSparqlView

This view is an aggregate of SparqlViews. The view itself does not create any index, but it references the already existing indices of the linked SparqlViews.

When performing queries on the sparql endpoint, this view will query all the underlying SparqlViews and then aggregate the results. The order how the results across the different SparqlView gets merged it is not deterministic.

If the caller does not have the permission views/query on all the projects defined on the aggregated view, only a subset ofindices (or none) will be selected, respecting the defined permissions.

AggregateSparqlView payload

{
  "@id": "{someid}",
  "@type": [ "View", "AggregateSparqlView"],
  "views": [
    {
        "project": "{project}",
        "viewId": "{viewId}"
    },
    ...
  ]
}

where…

  • {project}: String - the project, defined as {org_label}/{project_label}, where the {viewId} is located.
  • {viewId}: Iri - The view @id value to be aggregated.

Create an ElasticSearchView using POST

POST /v1/view/{org_label}/{project_label}
  {...}

The json payload:

  • If the @id value is found on the payload, this @id will be used.
  • If the @id value is not found on the payload, an @id will be generated as follows: base:{UUID}. The base is the prefix defined on the view’s project ({project_label}).

Example

Request
curl -XPOST -H "Content-Type: application/json" "https://nexus.example.com/v1/views/myorg/myproj" -d \
'{
  "@id": "https://bluebrain.github.io/nexus/vocabulary/myview",
  "@type": [
    "ElasticSearchView"
  ],
  "mapping": {
    "dynamic": false,
    "properties": {
      "@id": {
        "type": "keyword"
      },
      "@type": {
        "type": "keyword"
      },
      "name": {
        "type": "keyword"
      },
      "number": {
        "type": "long"
      },
      "bool": {
        "type": "boolean"
      }
    }
  },
  "includeMetadata": false,
  "includeDeprecated": false,
  "sourceAsText": false,
  "resourceSchemas": [
    "https://bluebrain.github.io/nexus/schemas/myschema"
  ],
  "resourceTypes": []
}'
Full source at GitHub
Payload
{
  "@id": "https://bluebrain.github.io/nexus/vocabulary/myview",
  "@type": [
    "ElasticSearchView"
  ],
  "mapping": {
    "dynamic": false,
    "properties": {
      "@id": {
        "type": "keyword"
      },
      "@type": {
        "type": "keyword"
      },
      "name": {
        "type": "keyword"
      },
      "number": {
        "type": "long"
      },
      "bool": {
        "type": "boolean"
      }
    }
  },
  "includeMetadata": false,
  "includeDeprecated": false,
  "sourceAsText": false,
  "resourceSchemas": [
    "https://bluebrain.github.io/nexus/schemas/myschema"
  ],
  "resourceTypes": []
}
Full source at GitHub
Response
{
  "@context": "https://bluebrain.github.io/nexus/contexts/resource.json",
  "@id": "nxv:myview",
  "@type": [
    "ElasticSearchView",
    "View"
  ],
  "_incoming": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/incoming",
  "_outgoing": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/outgoing",
  "_self": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview",
  "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/view",
  "_project": "https://nexus.example.com/v1/projects/myorg/myproj",
  "_rev": 1,
  "_deprecated": false,
  "_createdAt": "2018-09-18T16:39:22.748Z",
  "_createdBy": "https://nexus.example.com/v1/realms/myrealm/users/john",
  "_updatedAt": "2018-09-18T16:39:22.748Z",
  "_updatedBy": "https://nexus.example.com/v1/realms/myrealm/users/john"
}
Full source at GitHub

Create an ElasticSearchView using PUT

This alternative endpoint to create a view is useful in case the json payload does not contain an @id but you want to specify one. The @id will be specified in the last segment of the endpoint URI.

PUT /v1/views/{org_label}/{project_label}/{view_id}
  {...}

Note that if the payload contains an @id different from the {view_id}, the request will fail.

Example

Request
curl -XPUT -H "Content-Type: application/json" "https://nexus.example.com/v1/views/myorg/myproj/nxv:myview" -d \
'{
  "@type": [
    "ElasticSearchView",
  ],
  "mapping": {
    "dynamic": false,
    "properties": {
      "@id": {
        "type": "keyword"
      },
      "@type": {
        "type": "keyword"
      },
      "name": {
        "type": "keyword"
      },
      "number": {
        "type": "long"
      },
      "bool": {
        "type": "boolean"
      }
    }
  },
  "includeMetadata": false,
  "includeDeprecated": false,
  "sourceAsText": false,
  "resourceSchemas": [
    "https://bluebrain.github.io/nexus/schemas/myschema"
  ],
  "resourceTypes": []
}'
Full source at GitHub
Payload
{
  "@type": [
    "ElasticSearchView"
  ],
  "mapping": {
    "dynamic": false,
    "properties": {
      "@id": {
        "type": "keyword"
      },
      "@type": {
        "type": "keyword"
      },
      "name": {
        "type": "keyword"
      },
      "number": {
        "type": "long"
      },
      "bool": {
        "type": "boolean"
      }
    }
  },
  "includeMetadata": false,
  "includeDeprecated": false,
  "sourceAsText": false,
  "resourceSchemas": [
    "https://bluebrain.github.io/nexus/schemas/myschema"
  ],
  "resourceTypes": []
}
Full source at GitHub
Response
{
  "@context": "https://bluebrain.github.io/nexus/contexts/resource.json",
  "@id": "nxv:myview",
  "@type": [
    "ElasticSearchView",
    "View"
  ],
  "_incoming": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/incoming",
  "_outgoing": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/outgoing",
  "_self": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview",
  "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/view",
  "_project": "https://nexus.example.com/v1/projects/myorg/myproj",
  "_rev": 1,
  "_deprecated": false,
  "_createdAt": "2018-09-18T16:39:22.748Z",
  "_createdBy": "https://nexus.example.com/v1/realms/myrealm/users/john",
  "_updatedAt": "2018-09-18T16:39:22.748Z",
  "_updatedBy": "https://nexus.example.com/v1/realms/myrealm/users/john"
}
Full source at GitHub

Update an ElasticSearchView

This operation overrides the payload.

In order to ensure a client does not perform any changes to a view without having had seen the previous revision of the view, the last revision needs to be passed as a query parameter.

PUT /v1/views/{org_label}/{project_label}/{view_id}?rev={previous_rev}
  {...}

… where {previous_rev} is the last known revision number for the view.

Example

Request
curl -XPUT -H "Content-Type: application/json" "https://nexus.example.com/v1/views/myorg/myproj/nxv:myview?rev=1" -d \
'{
  "@type": [
    "ElasticSearchView"
  ],
  "mapping": {
    "dynamic": false,
    "properties": {
      "@id": {
        "type": "keyword"
      },
      "@type": {
        "type": "keyword"
      },
      "name": {
        "type": "keyword"
      },
      "number": {
        "type": "long"
      },
      "bool": {
        "type": "boolean"
      }
    }
  },
  "includeMetadata": false,
  "includeDeprecated": false,
  "sourceAsText": false,
  "resourceSchemas": [
    "https://bluebrain.github.io/nexus/schemas/myschema"
  ],
  "resourceTypes": []
}'
Full source at GitHub
Payload
{
  "@type": [
    "ElasticSearchView"
  ],
  "mapping": {
    "dynamic": false,
    "properties": {
      "@id": {
        "type": "keyword"
      },
      "@type": {
        "type": "keyword"
      },
      "name": {
        "type": "keyword"
      },
      "number": {
        "type": "long"
      },
      "bool": {
        "type": "boolean"
      }
    }
  },
  "includeMetadata": false,
  "includeDeprecated": false,
  "sourceAsText": false,
  "resourceSchemas": [
    "https://bluebrain.github.io/nexus/schemas/myschema"
  ],
  "resourceTypes": []
}
Full source at GitHub
Response
{
  "@context": "https://bluebrain.github.io/nexus/contexts/resource.json",
  "@id": "nxv:myview",
  "@type": [
    "ElasticSearchView",
    "View",
  ],
  "_incoming": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/incoming",
  "_outgoing": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/outgoing",
  "_self": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview",
  "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/view",
  "_project": "https://nexus.example.com/v1/projects/myorg/myproj",
  "_rev": 2,
  "_deprecated": false,
  "_createdAt": "2018-09-18T16:39:22.748Z",
  "_createdBy": "https://nexus.example.com/v1/realms/myrealm/users/john",
  "_updatedAt": "2018-09-18T16:42:22.748Z",
  "_updatedBy": "https://nexus.example.com/v1/realms/myrealm/users/john"
}
Full source at GitHub

Create an AggregateElasticSearchView using PUT

This alternative endpoint to create a view is useful in case the json payload does not contain an @id but you want to specify one. The @id will be specified in the last segment of the endpoint URI.

PUT /v1/views/{org_label}/{project_label}/{view_id}
  {...}

Note that if the payload contains an @id different from the {view_id}, the request will fail.

Example

Request
curl -XPUT -H "Content-Type: application/json" "https://nexus.example.com/v1/views/myorg/myproj3/nxv:myagg" -d \
'{
  "@context": {
    "nxv": "https://bluebrain.github.io/nexus/vocabulary/"
  },
  "@type": [
    "AggregateElasticSearchView",
  ],
  "views": [
    {
      "project": "myorg/myproj",
      "viewId": "nxv:myview"
    },
    {
      "project": "myorg/myproj2",
      "viewId": "nxv:myview2"
    }
  ]
}'
Full source at GitHub
Payload
{
  "@context": {
    "nxv": "https://bluebrain.github.io/nexus/vocabulary/"
  },
  "@type": [
    "AggregateElasticSearchView"
  ],
  "views": [
    {
      "project": "myorg/myproj",
      "viewId": "nxv:myview"
    },
    {
      "project": "myorg/myproj2",
      "viewId": "nxv:myview2"
    }
  ]
}
Full source at GitHub
Response
{
  "@context": "https://bluebrain.github.io/nexus/contexts/resource.json",
  "@id": "nxv:myview",
  "@type": [
    "AggregateElasticSearchView",
    "View"
  ],
  "_incoming": "https://nexus.example.com/v1/schemas/myorg/myproj3/nxv:myagg/incoming",
  "_outgoing": "https://nexus.example.com/v1/schemas/myorg/myproj3/nxv:myagg/outgoing",
  "_self": "https://nexus.example.com/v1/schemas/myorg/myproj3/nxv:myagg",
  "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/view",
  "_project": "https://nexus.example.com/v1/projects/myorg/myproj3",
  "_rev": 1,
  "_deprecated": false,
  "_createdAt": "2018-09-18T16:39:22.748Z",
  "_createdBy": "https://nexus.example.com/v1/realms/myrealm/users/john",
  "_updatedAt": "2018-09-18T16:39:22.748Z",
  "_updatedBy": "https://nexus.example.com/v1/realms/myrealm/users/john"
}
Full source at GitHub

Tag a View

Links a view’s revision to a specific name.

Tagging a view is considered to be an update as well.

POST /v1/views/{org_label}/{project_label}/{view_id}/tags?rev={previous_rev}
  {
    "tag": "{name}",
    "rev": {rev}
  }

… where

  • {previous_rev}: Number - the last known revision for the resolver.
  • {name}: String - label given to the view at specific revision.
  • {rev}: Number - the revision to link the provided {name}.

Example

Request
curl -XPOST -H "Content-Type: application/json" "https://nexus.example.com/v1/views/myorg/myproj/nxv:myview/tags?rev=2" -d \
'{
  "tag": "mytag",
  "rev": 1
}'
Full source at GitHub
Payload
{
  "tag": "mytag",
  "rev": 1
}
Full source at GitHub
Response
{
  "@context": "https://bluebrain.github.io/nexus/contexts/resource.json",
  "@id": "nxv:myview",
  "@type": [
    "ElasticSearchView",
    "View"
  ],
  "_incoming": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/incoming",
  "_outgoing": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/outgoing",
  "_self": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview",
  "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/view",
  "_project": "https://nexus.example.com/v1/projects/myorg/myproj",
  "_rev": 3,
  "_deprecated": false,
  "_createdAt": "2018-09-18T16:39:22.748Z",
  "_createdBy": "https://nexus.example.com/v1/realms/myrealm/users/john",
  "_updatedAt": "2018-09-18T16:52:22.748Z",
  "_updatedBy": "https://nexus.example.com/v1/realms/myrealm/users/john"
}
Full source at GitHub

Deprecate a view

Locks the view, so no further operations can be performed. It also stops indexing any more resources into it.

Deprecating a view is considered to be an update as well.

DELETE /v1/views/{org_label}/{project_label}/{view_id}?rev={previous_rev}

… where {previous_rev} is the last known revision number for the view.

Example

Request
curl -XDELETE "https://nexus.example.com/v1/views/myorg/myproj/nxv:myview?rev=5"
Full source at GitHub
Response
{
  "@context": "https://bluebrain.github.io/nexus/contexts/resource.json",
  "@id": "nxv:myview",
  "@type": [
    "ElasticSearchView",
    "View"
  ],
  "_incoming": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/incoming",
  "_outgoing": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/outgoing",
  "_self": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview",
  "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/view",
  "_project": "https://nexus.example.com/v1/projects/myorg/myproj",
  "_rev": 6,
  "_deprecated": true,
  "_createdAt": "2018-09-18T16:39:22.748Z",
  "_createdBy": "https://nexus.example.com/v1/realms/myrealm/users/john",
  "_updatedAt": "2018-09-18T17:10:22.748Z",
  "_updatedBy": "https://nexus.example.com/v1/realms/myrealm/users/john"
}
Full source at GitHub

Fetch a view

When fetching a view, the response format can be chosen through HTTP content negotiation, using the Accept HTTP header.

  • application/ld+json: JSON-LD output response. Further specifying the query parameter format=compacted|expanded will provide with the JSON-LD compacted document form or the expanded document form.
  • application/n-triples: RDF n-triples response, as defined by the w3.
  • text/vnd.graphviz: A DOT response.

If Accept: */* HTTP header is present, Nexus defaults to the JSON-LD output in compacted form.

GET /v1/views/{org_label}/{project_label}/{view_id}?rev={rev}&tag={tag}

where … - {rev}: Number - the targeted revision to be fetched. This field is optional and defaults to the latest revision. - {tag}: String - the targeted tag to be fetched. This field is optional. {rev} and {tag} fields cannot be simultaneously present.

Example

Request
curl "https://nexus.example.com/v1/views/myorg/myproj/nxv:myview"
Full source at GitHub
Response
{
  "@context": [
    "https://bluebrain.github.io/nexus/contexts/view.json",
    "https://bluebrain.github.io/nexus/contexts/resource.json"
  ],
  "@id": "nxv:myview2",
  "@type": [
    "ElasticSearchView",
    "View"
  ],
  "includeMetadata": false,
  "includeDeprecated": false,
  "mapping": {
    "dynamic": false,
    "properties": {
      "@id": {
        "type": "keyword"
      },
      "@type": {
        "type": "keyword"
      },
      "bool": {
        "type": "boolean"
      },
      "name": {
        "type": "keyword"
      },
      "number": {
        "type": "long"
      }
    }
  },
  "resourceSchemas": [
    "https://bluebrain.github.io/nexus/schemas/myschema"
  ],
  "resourceTypes": [],
  "sourceAsText": false,
  "_uuid": "4f90ceff-45b7-442d-8536-d41705321d50",
  "_incoming": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/incoming",
  "_outgoing": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/outgoing",
  "_self": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview",
  "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/view",
  "_project": "https://nexus.example.com/v1/projects/myorg/myproj",
  "_createdAt": "2018-09-18T16:39:22.748Z",
  "_createdBy": "https://nexus.example.com/v1/realms/myrealm/users/john",
  "_updatedAt": "2018-09-18T17:10:22.748Z",
  "_updatedBy": "https://nexus.example.com/v1/realms/myrealm/users/john",
  "_rev": 4,
  "_deprecated": true
}
Full source at GitHub

Fetch a view original payload

GET /v1/views/{org_label}/{project_label}/{view_id}/source?rev={rev}&tag={tag}

where … - {rev}: Number - the targeted revision to be fetched. This field is optional and defaults to the latest revision. - {tag}: String - the targeted tag to be fetched. This field is optional. {rev} and {tag} fields cannot be simultaneously present.

Example

Request
curl "https://nexus.example.com/v1/views/myorg/myproj/nxv:myview/source"
Full source at GitHub
Response
{
  "@context": [
    "https://bluebrain.github.io/nexus/contexts/view.json",
    "https://bluebrain.github.io/nexus/contexts/resource.json"
  ],
  "@id": "nxv:myview2",
  "@type": [
    "ElasticSearchView",
    "View"
  ],
  "includeMetadata": false,
  "includeDeprecated": false,
  "mapping": {
    "dynamic": false,
    "properties": {
      "@id": {
        "type": "keyword"
      },
      "@type": {
        "type": "keyword"
      },
      "bool": {
        "type": "boolean"
      },
      "name": {
        "type": "keyword"
      },
      "number": {
        "type": "long"
      }
    }
  },
  "resourceSchemas": [
    "https://bluebrain.github.io/nexus/schemas/myschema"
  ],
  "resourceTypes": [],
  "sourceAsText": false,
  "_uuid": "4f90ceff-45b7-442d-8536-d41705321d50"
}
Full source at GitHub

Fetch view statistics

GET /v1/views/{org_label}/{project_label}/{view_id}/statistics
Note

View statistics are currently unavailable for AggregateElasticSearchView.

Example

Request
curl "https://nexus.example.com/v1/views/myorg/myproj/nxv:myview/statistics"
Full source at GitHub
Response
{
  "@context": "https://bluebrain.github.io/nexus/contexts/view.json",
  "delayInSeconds": 699451,
  "discardedEvents": 3,
  "evaluatedEvents": 263,
  "lastEventDateTime": "2019-03-12T16:59:20.296Z",
  "lastProcessedEventDateTime": "2019-03-04T14:41:49.545Z",
  "processedEvents": 266,
  "remainingEvents": 31214,
  "totalEvents": 31480
}
Full source at GitHub

where:

  • totalEvents - total number of events in the project
  • processedEvents - number of events that have been considered by the view
  • remainingEvents - number of events that remain to be considered by the view
  • discardedEvents - number of events that have been discarded (were not evaluated due to filters, e.g. did not match schema, tag or type defined in the view)
  • evaluatedEvents - number of events that have been used to update an index
  • lastEventDateTime - timestamp of the last event in the project
  • lastProcessedEventDateTime - timestamp of the last event processed by the view
  • delayInSeconds - number of seconds between the last processed event timestamp and the last known event timestamp

List views

GET /v1/views/{org_label}/{project_label}?from={from}&size={size}&deprecated={deprecated}&rev={rev}&type={type}&createdBy={createdBy}&updatedBy={updatedBy}&q={search}

where…

  • {from}: Number - is the parameter that describes the offset for the current query; defaults to 0
  • {size}: Number - is the parameter that limits the number of results; defaults to 20
  • {deprecated}: Boolean - can be used to filter the resulting views based on their deprecation status
  • {rev}: Number - can be used to filter the resulting views based on their revision value
  • {type}: Iri - can be used to filter the resulting views based on their @type value. This parameter can appear multiple times, filtering further the @type value.
  • {createdBy}: Iri - can be used to filter the resulting views based on their creator
  • {updatedBy}: Iri - can be used to filter the resulting views based on the person which performed the last update
  • {search}: String - can be provided to select only the views in the collection that have attribute values matching (containing) the provided string

Example

Request
curl "https://nexus.example.com/v1/views/myorg/myproj"
Full source at GitHub
Response
{
  "@context": [
    "https://bluebrain.github.io/nexus/contexts/search.json",
    "https://bluebrain.github.io/nexus/contexts/resource.json"
  ],
  "_total": 3,
  "_results": [
    {
      "@id": "https://bluebrain.github.io/nexus/vocabulary/defaultElasticIndex",
      "@type": [
        "https://bluebrain.github.io/nexus/vocabulary/View",
        "https://bluebrain.github.io/nexus/vocabulary/Alpha",
        "https://bluebrain.github.io/nexus/vocabulary/ElasticSearchView"
      ],
      "_incoming": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:defaultElasticIndex/incoming",
      "_outgoing": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:defaultElasticIndex/outgoing",
      "_self": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:defaultElasticIndex",
      "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/view",
      "_project": "https://nexus.example.com/v1/projects/myorg/myproj",
      "_rev": 1,
      "_deprecated": false,
      "_createdAt": "2018-09-18T16:39:22.748Z",
      "_createdBy": "https://nexus.example.com/v1/realms/myrealm/users/john",
      "_updatedAt": "2018-09-18T17:10:22.748Z",
      "_updatedBy": "https://nexus.example.com/v1/realms/myrealm/users/john"
    },
    {
      "@id": "https://bluebrain.github.io/nexus/vocabulary/defaultSparqlIndex",
      "@type": [
        "https://bluebrain.github.io/nexus/vocabulary/View",
        "https://bluebrain.github.io/nexus/vocabulary/SparqlView"
      ],
      "_incoming": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:defaultSparqlIndex/incoming",
      "_outgoing": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:defaultSparqlIndex/outgoing",
      "_self": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:defaultSparqlIndex",
      "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/view",
      "_project": "https://nexus.example.com/v1/projects/myorg/myproj",
      "_rev": 1,
      "_deprecated": false,
      "_createdAt": "2018-09-18T16:39:22.748Z",
      "_createdBy": "https://nexus.example.com/v1/realms/myrealm/users/john",
      "_updatedAt": "2018-09-18T17:10:22.748Z",
      "_updatedBy": "https://nexus.example.com/v1/realms/myrealm/users/john"
    },
    {
      "@id": "https://bluebrain.github.io/nexus/vocabulary/myview2",
      "@type": [
        "https://bluebrain.github.io/nexus/vocabulary/ElasticSearchView",
        "https://bluebrain.github.io/nexus/vocabulary/View",
        "https://bluebrain.github.io/nexus/vocabulary/Alpha"
      ],
      "_incoming": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/incoming",
      "_outgoing": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/outgoing",
      "_self": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview",
      "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/view",
      "_project": "https://nexus.example.com/v1/projects/myorg/myproj",
      "_rev": 4,
      "_deprecated": true,
      "_createdAt": "2018-09-18T16:39:22.748Z",
      "_createdBy": "https://nexus.example.com/v1/realms/myrealm/users/john",
      "_updatedAt": "2018-09-18T17:10:22.748Z",
      "_updatedBy": "https://nexus.example.com/v1/realms/myrealm/users/john"
    }
  ],
  "_next": "https://nexus.example.com/v1/views/myorg/myproj?after=%5B1559045718752,%22https://bluebrain.github.io/nexus/vocabulary/myview29%22%5D"
}
Full source at GitHub

ElasticSearch query

Provides search functionality on the ElasticSearchView or AggregateElasticSearchView content.

POST /v1/views/{org_label}/{project_label}/{view_id}/_search
  {...}

The supported payload is defined on the ElasticSearch documentation

The string documents is used as a prefix of the default ElasticSearch view_id

Example

Request
curl -XPOST -H "Content-Type: application/json" "https://nexus.example.com/v1/views/myorg/myproj/nxv:myview/_search" -d \
'{
  "query": {
    "term": {
      "_deprecated": true
    }
  }
}'
Full source at GitHub
Response
{
  "_shards": {
    "failed": 0,
    "skipped": 0,
    "successful": 0,
    "total": 0
  },
  "hits": {
    "hits": [
      {
        "_score": 1.2039728,
        "_id": "http://example.com/myview",
        "_index": "kg_v1_803da242-d510-4e1a-a12d-d0e0b7018a41_684bd815-9273-46f4-ac1c-0383d4a98254_1",
        "_source": {
          "@id": "http://example.com/myview",
          "@type": [
            "https://bluebrain.github.io/nexus/vocabulary/View",
            "https://bluebrain.github.io/nexus/vocabulary/ElasticSearchView",
            "https://bluebrain.github.io/nexus/vocabulary/Alpha"
          ],
          "_original_source": "{\"mapping\":\"{\\\"dynamic\\\":false,\\\"properties\\\":{\\\"@id\\\":{\\\"type\\\":\\\"keyword\\\"},\\\"@type\\\":{\\\"type\\\":\\\"keyword\\\"},\\\"name\\\":{\\\"type\\\":\\\"keyword\\\"},\\\"number\\\":{\\\"type\\\":\\\"long\\\"},\\\"bool\\\":{\\\"type\\\":\\\"boolean\\\"}}}\",\"_uuid\":\"89dd9858-cf87-4c46-94c2-24da0fcae0aa\",\"@context\":\"https://bluebrain.github.io/nexus/contexts/view\",\"@type\":[\"View\",\"ElasticSearchView\"],\"includeMetadata\":true,\"sourceAsText\":false}",
          "_incoming": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/incoming",
          "_outgoing": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview/outgoing",
          "_self": "https://nexus.example.com/v1/schemas/myorg/myproj/nxv:myview",
          "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/view",
          "_project": "https://nexus.example.com/v1/projects/myorg/myproj",
          "_rev": 6,
          "_deprecated": true,
          "_createdAt": "2018-09-18T16:39:22.748Z",
          "_createdBy": "https://nexus.example.com/v1/realms/myrealm/users/john",
          "_updatedAt": "2018-09-18T17:10:22.748Z",
          "_updatedBy": "https://nexus.example.com/v1/realms/myrealm/users/john"
        },
        "_type": "doc"
      }
    ],
    "max_score": 1.2039728,
    "total": 1
  },
  "timed_out": false,
  "took": 11
}
Full source at GitHub

SparQL query

Provides search functionality on the SparqlView content.

POST /v1/views/{org_label}/{project_label}/graph/sparql
  "..."

The supported payload is defined on the SparQL documentation The Content-Type HTTP header for this request is application/sparql-query.

Example

Request
curl -XPOST -H "Content-Type: application/sparql-query" "https://nexus.example.com/v1/views/myorg/myproj/graph/sparql" -d \
'SELECT ?s where {?s ?p ?o} LIMIT 2'
Full source at GitHub
Response
{
  "head": {
    "vars": [
      "s"
    ]
  },
  "results": {
    "bindings": [
      {
        "s": {
          "type": "uri",
          "value": "http://example.com/myview"
        }
      },
      {
        "s": {
          "type": "uri",
          "value": "http://example.com/other"
        }
      }
    ]
  }
}
Full source at GitHub

Views internals

When an asynchronous process that reads the view events from the Primary Store gets triggered, a new index (SparQL or ElasticSearch) gets created. After that, an endpoint (/sparql for SparQL view or /_search for ElasticSearch view) becomes available. The client can then perform queries against those endpoints.

The view provides the configuration of the index and defines which Events are going to be indexed.

View internals