Wikipedia Storage

Query the latest Wikipedia dump processed with JSONpedia.

MongoDB Query

GET /storage/mongo/select

Specify a data selector and optionally a filter and a resultset limit

Query

MongoDB Map/Reduce

GET /storage/mongo/mapred

Specify a data criteria selector, a map/reduce functions and optionally a resultset limit

Query

Elasticsearch Query

GET /storage/elastic/select

Specify a data selector and optionally a filter and a resultset limit

Query

Quick API reference

Examples

GET /storage/mongo/select API

HTTP GET requests can be sent to the URL:

http://...//storage/mongo/select?q=<query>&filter=<filter>&limit=<limit>
with the following parameters:
Parameter Description Required
q Selector to apply over stored data. See mongo selector syntax. True
filter Filter criteria to be applied to the result. See filter syntax. False
limit Limit of returned results, max allowed value: 1000. False

The response is the input resource converted to the desired output format. Processing errors are encoded in error codes table.

GET /storage/mongo/mapred API

HTTP GET requests can be sent to the URL:

http://...//storage/mongo/mapred?criteria=<criteria>&map=<map>&reduce=<reduce>&limit=<limit>
with the following parameters:
Parameter Description Required
criteria Selector to apply over stored data. See mongo selector syntax (criteria). True
map Javascript Map function. See MongoDB Map-Reduce manual. True
reduce Javascript Reduce function. See MongoDB Map-Reduce manual. True
limit Limit of returned results, max allowed value: 1000. False

The response is the input resource converted to the desired output format. Processing errors are encoded in error codes table.

GET /storage/elastic/select API

HTTP GET requests can be sent to the URL:

http://...//storage/elastic/select?q=<query>&filter=<filter>&limit=<limit>
with the following parameters:
Parameter Description Required
q Selector to apply over stored data. See elastic selector syntax. True
filter Filter criteria to be applied to the result. See filter syntax. False
limit Limit of returned results, max allowed value: 1000. False

The response is the input resource converted to the desired output format. Processing errors are encoded in error codes table.

Output formats

Supported output format are:

Output format Media type Description
JSON application/json Produces a JSON object which sections are described in Mongo select output format

Error codes

Processing errors are reported as HTTP status codes with short text/plain messages.
The following status codes can be returned:

Code Reason
200 OK Success.
400 Bad Request Invalid parameters.
500 Internal Error Generic error occurred.

Mongo Selector Syntax

The MongoDB selector is an expression which describes a criteria to select JSONpedia documents stored into the configured MongoDB store. A selector is composed of a selection part where it is possible to define conditions over fields and a projection part where it is possible do define which part of the documents satisfying the selection must be returned.
MongoDB selector has been introduced to avoid user to write queries using the JSON syntax imposed by MongoDB.

Examples of selectors

Select document with id 706 and return only the value of field "name".
_id = 706 -> name
Select all documents with version major or equals to 10 and for these return the value of field "categories" (which is a list).
version >= 10 -> content.categories

Selector syntax

The full MongoDB selector syntax is reported below.

<selector>      ::= <criteria> "->" <projection> ;
<criteria>      ::= <node-criteria> | <node-criteria> "," <criteria> ;
<node-criteria> ::=  <field> <operator> <value>
<projection>    ::= <field> | <field> "." <projection> ;
<operator>      ::= '==' | '!=' | '<' | '>' | '<=' | '>=' ;
<field>         ::= <JSON-field-name> ;
<value>         ::= <String> | <number> ;
<number>        ::= '#' <Number> ;


Elasticsearch Selector Syntax

The Elasticsearch selector is an expression which describes a criteria to select JSONpedia documents stored in Elasticsearch. A selector can be a criteria (in this case applies on every field) or a criteria applied on a field. The criteria must respect the query syntax defined by Elasticsearch (see reference below).
Elasticsearch selector has been introduced to avoid user to write queries using the JSON syntax imposed by Elasticsearch.

Examples of selectors

Select all documents which field "name" contains string "Albert Einstein".

name:"Albert Einstein"
Select all documents which field "name" contains word "quick" or word "brown".
name:"quick OR brown"
Select all documents which field "name" contains word "quick" and word "brown".
name:"quick AND brown"

Selector syntax

The full Elasticsearch selector syntax is reported below.

<selector> ::= <criteria> | <field> : <criteria> ;
<field>    ::= <JSON-field-name> ;
<criteria> ::= <Query-String-Syntax> ; (See full specification)


Request Limit

Defines the limit in size of results. Integer value >= 0.
0 means no limit.


Mongo Select Output Format

The service returns an object with following fields:

The output format is composed as described in the example below.

{
    query-explain: "criterias: [_id eq 736], projections: [content, title, _id, name, version]",
    mongo-selection: "{ "_id" : 736}",
    mongo-projection: "{ "_id" : 1 , "content" : 1 , "title" : 1 , "name" : 1 , "version" : 1}",
    count: 1,
    result: [
        [
            {
                _id: 736,
                version: 8494089,
                name: "Albert Einstein",
                content: { ... }
            }
        ]
    ]
}