Skip to main content
Hitachi Vantara Knowledge

SQL queries

You can search some indexes using SQL queries.

When you search an index using a SQL query:

  • The SQL SELECT clause specifies which fields are retrieved from the index.
  • The SQL FROM clause specifies the index or indexes to extract documents from.
  • The SQL WHERE clause limits which documents are retrieved from the index.

For more information on SQL, see Solr SQL documentation.

Supported indexes

You can use SQL queries only with Solr indexes at version 6 or later; this includes HCI Indexes. You cannot use SQL queries to search HDDS, Elasticsearch indexes, or external Solr 5 indexes.

For information on the supported index types, see Index collections.

NoteIf an index name contains only numbers, you cannot search it using SQL queries.
Supported interfaces

You cannot submit SQL queries using the Admin App UI, but you can submit them through both the administrative and search REST APIs and CLIs.

Example SQL query for document IDs

This example uses cURL and the search REST API to query for all unique values of the HCI_id field across all documents in the index called index1.

Request:

curl -X POST --header 'Content-Type: application/json'
--header 'Accept: application/json'
-d '{
  "queryString": "SELECT HCI_id FROM index1",
  "indexName": "index1"
}' 'https://mySystem.example.com:8000/ap...arch/query/sql'

Response:

{
  "modelVersion":"1.2.0",
  "resultSet":[
    {
            "modelVersion":"1.2.0",
            "resultFields" : [
                {
               "HCI_id":"http://example.com/doc1"
                }
              ]
    },
    {
             "modelVersion":"1.2.0",
             "resultFields" : [
                {
                  "HCI_id":"http://example.com/doc2"
                }
              ]
    }
  ]
}

 

  • Was this article helpful?