-
Notifications
You must be signed in to change notification settings - Fork 22
Query Results (Spider)
[Table of Contents](https://github.com/dell-oss/Doradus/wiki/Spider Databases: Table-of-Contents) | Previous | Next
Spider Object Queries: Query Results
An object query always returns an output entity even if there are no objects matching the query request. The outer element is results
, which contains a single docs
element, which contains one doc
element for each object that matched the query expression. Examples for various field types are shown below.
If the query returns no results, the docs
element is empty. In XML:
<results> <docs/> </results>
In JSON:
{"results": { "docs": [] }}
This object query requests all scalar fields of Person
objects whose LastName
is Garn
:
GET /Msgs/Person/_query?q=LastName:Garn&f=*
In XML, the result looks like this:
<results>
<docs>
<doc>
<field name="Department">Field Sales</field>
<field name="FirstName">Chris</field>
<field name="LastName">Garn</field>
<field name="Name">Chris Garn</field>
<field name="Office">Aliso Viejo 5</field>
<field name="_ID">07Z094KNjmEsqMoV/yNI0g==</field>
</doc>
<doc>
<field name="Department">Sales Operations</field>
<field name="FirstName">Jim</field>
<field name="LastName">Garn</field>
<field name="Name">Jim Garn</field>
<field name="Office">Aliso Viejo 5</field>
<field name="_ID">kUNaqNJ2ymmb07jHY9OPOw==</field>
</doc>
<doc>
<field name="Department">Admin</field>
<field name="FirstName">Doug</field>
<field name="LastName">Garn</field>
<field name="Name">Doug Garn</field>
<field name="Office">Aliso Viejo 5</field>
<field name="_ID">m1yYabbtytmjw+e8OCz1dg==</field>
</doc>
</docs>
</results>
In JSON:
{"results": {
"docs": [
{"doc": {
"Department": "Field Sales",
"FirstName": "Chris",
"LastName": "Garn",
"Name": "Chris Garn",
"Office": "Aliso Viejo 5",
"_ID": "07Z094KNjmEsqMoV/yNI0g=="
}},
{"doc": {
"Department": "Sales Operations",
"FirstName": "Jim",
"LastName": "Garn",
"Name": "Jim Garn",
"Office": "Aliso Viejo 5",
"_ID": "kUNaqNJ2ymmb07jHY9OPOw=="
}},
{"doc": {
"Department": "Admin",
"FirstName": "Doug",
"LastName": "Garn",
"Name": "Doug Garn",
"Office": "Aliso Viejo 5",
"_ID": "m1yYabbtytmjw+e8OCz1dg=="
}}
]
}}
The _ID
field of each object is always included. SV scalar fields are returned only if they have values. If a group contains any leaf fields with values, they are returned at the outer (doc
) level: the group field is not included.
When timestamp fields are returned, the fractional component of a value is suppressed when it is zero. For example:
2012-01-06 19:59:51
This value means that the seconds component is a whole value (51). If a seconds component has a fractional value, it is displayed with 3 digits to the right of the decimal place. Example:
2012-01-06 19:59:51.385
The following object query requests the MV scalar field Tags
:
GET /Msgs/Message/_query?q=*&f=Tags
A typical result is shown below:
<results>
<docs>
<doc>
<field name="Tags">
<value>AfterHours</value>
</field>
<field name="_ID">+/pz/q4Jf8Rc2HK9Cg08TA==</field>
</doc>
<doc>
<field name="Tags">
<value>Customer</value>
<value>AfterHours</value>
</field>
<field name="_ID">+/wqUBY1WsGtb7zjpKYf7w==</field>
</doc>
<doc>
<field name="Tags"/>
<field name="_ID">+1ZQASSaJei0HoGz6GdINA==</field>
</doc>
</docs>
</results>
The same request in JSON is shown below:
{"results": {
"docs": [
{"doc": {
"Tags": ["AfterHours"],
"_ID": "+/pz/q4Jf8Rc2HK9Cg08TA=="
}},
{"doc": {
"Tags": ["Customer","AfterHours"],
"_ID": "+/wqUBY1WsGtb7zjpKYf7w=="
}},
{"doc": {
"Tags": [],
"_ID": "+1ZQASSaJei0HoGz6GdINA=="
}}
],
}}
As shown, all values of the Tags
field are returned, and an element is included even when it is null, as it is for the third object.
When a query has no fields parameter or explicitly requests "*", only scalar fields of perspective objects are returned. When the fields parameter includes a link field, by default only the _ID
field of each linked object is returned. If a link field is requested that has no values, an empty list is returned. For example, consider this object query:
GET /Msgs/Person/_query?q=LastName=Powell&f=Manager,DirectReports
This query searches for people whose LastName
is Powell
and requests the Manager
and DirectReports
links. An example result in XML:
<results>
<docs>
<doc>
<field name="_ID">gfNqhYF7LgBAtKTdIx3BKw==</field>
<field name="DirectReports">
<doc>
<field name="_ID">mKjYJmmLPoTVxJu2xdFmUg==</field>
</doc>
</field>
<field name="Manager">
<doc>
<field name="_ID">nLOCpa7aH/Y3zDrnMqG6Fw==</field>
</doc>
</field>
</doc>
<doc>
<field name="_ID">sHUm0PEKu3gQDDNIHHWv1g==</field>
<field name="DirectReports"/>
<field name="Manager">
<doc>
<field name="_ID">tkSQlrRqaeHsGvRU65g9HQ==</field>
</doc>
</field>
</doc>
</docs>
</results>
In JSON:
{"results": {
"docs": [
{"doc": {
"\_ID": "gfNqhYF7LgBAtKTdIx3BKw==",
"DirectReports": [
{"doc": {
"\_ID": "mKjYJmmLPoTVxJu2xdFmUg=="
}}
],
"Manager": [
{"doc": {
"\_ID": "nLOCpa7aH/Y3zDrnMqG6Fw=="
}}
]
}},
{"doc": {
"\_ID": "sHUm0PEKu3gQDDNIHHWv1g==",
"DirectReports": [],
"Manager": [
{"doc": {
"\_ID": "tkSQlrRqaeHsGvRU65g9HQ=="
}}
]
}}
]
}}
As shown, requested link fields are returned even if they have no values. By default, only the _ID
values of linked objects are included.
Technical Documentation
[Doradus OLAP Databases](https://github.com/dell-oss/Doradus/wiki/Doradus OLAP Databases)
- Architecture
- OLAP Database Overview
- OLAP Data Model
- Doradus Query Language (DQL)
- OLAP Object Queries
- OLAP Aggregate Queries
- OLAP REST Commands
- Architecture
- Spider Database Overview
- Spider Data Model
- Doradus Query Language (DQL)
- Spider Object Queries
- Spider Aggregate Queries
- Spider REST Commands
- [Installing and Running Doradus](https://github.com/dell-oss/Doradus/wiki/Installing and Running Doradus)
- [Deployment Guidelines](https://github.com/dell-oss/Doradus/wiki/Deployment Guidelines)
- [Doradus Configuration and Operation](https://github.com/dell-oss/Doradus/wiki/Doradus Configuration and Operation)
- [Cassandra Configuration and Operation](https://github.com/dell-oss/Doradus/wiki/Cassandra Configuration and Operation)