See: Description
| Class | Description |
|---|---|
| JsonQueryParser |
This class is a helper that enables users to easily use the SIREn's JSON
query parser.
|
| Exception | Description |
|---|---|
| ParseException |
Exception thrown by the
JsonQueryParser if an error occurs during
parsing. |
A JSON Query is composed of one top-level object, which can be either:
node) object that represents a
NodeBooleanQuery or a NodePrimitiveQuery; or
twig) object that represents a TwigQuery; or
boolean) object that represents a
BooleanQuery of node and twig query objects.
KeywordQueryParser. Examples of appropriately formatted keyword
queries can be found in the
keyword query syntax documentation.
"node" : {
"query" : String, // Node boolean query expression - Mandatory
"level" : int, // Node level constraint - Optional
"range" : [int, int] // Node range constraint - Optional
}
"twig" : {
"root" : String, // Node boolean query expression - Optional
"level" : int, // Node level constraint - Optional
"range" : [int, int] // Node range constraint - Optional
"child" : [ Clause ] // Array of child clauses - Optional
"descendant" : [ Clause ] // Array of descendant clauses - Optional
}
"boolean" : [ Clause ] // Array of clauses - Mandatory
{
"occur" : String, // Boolean operator (MUST, MUST_NOT, SHOULD) - Mandatory
// With either a node object
"node" : { ... }, // Node object - Mandatory
// Or a twig object
"twig" : { ... }, // Twig object - Mandatory
// A level field is mandatory only for descendant clauses
"level" : int
}
{
"node" : {
"query" : "\"Marie Antoinette\""
}
}
{
"twig" : {
"root" : "genre",
"child" : [ {
"occur" : "MUST",
"node" : {
"query" : "Drama"
}
} ]
}
}
Such a twig query is the basic building block to query to a particular
field name of a JSON object. The field name is always the root of the twig
query and the field value is defined as a child clause.
More complex twig queries can be constructed by using nested twig queries or using more than one child (or descendant) clause.
{
"twig" : {
"root" : "director",
"child" : [ {
"occur" : "MUST",
"twig" : {
"child" : [ {
"occur" : "MUST",
"twig" : {
"root" : "last_name",
"child" : [ {
"occur" : "MUST",
"node" : {
"query" : "Eastwood"
}
} ]
}
}, {
"occur" : "MUST",
"twig" : {
"root" : "first_name",
"child" : [ {
"occur" : "MUST",
"node" : {
"query" : "Clint"
}
} ]
}
} ]
}
} ]
}
}
{
"boolean" : [ {
"occur" : "MUST",
"twig" : {
"root" : "genre",
"child" : [ {
"occur" : "MUST",
"node" : {
"query" : "Drama"
}
} ]
}
}, {
"occur" : "MUST",
"twig" : {
"root" : "year",
"child" : [ {
"occur" : "MUST",
"node" : {
"query" : "2010"
}
} ]
}
} ]
}
QueryBuilder.Copyright © 2014. All rights reserved.