layout: doc_page

Search Queries

A search query returns dimension values that match the search specification.

{
  "queryType": "search",
  "dataSource": "sample_datasource",
  "granularity": "day",
  "searchDimensions": [
    "dim1",
    "dim2"
  ],
  "query": {
    "type": "insensitive_contains",
    "value": "Ke"
  },
  "sort" : {
    "type": "lexicographic"
  },
  "intervals": [
    "2013-01-01T00:00:00.000/2013-01-03T00:00:00.000"
  ]
}

There are several main parts to a search query:

propertydescriptionrequired?
queryTypeThis String should always be “search”; this is the first thing Druid looks at to figure out how to interpret the query.yes
dataSourceA String or Object defining the data source to query, very similar to a table in a relational database. See DataSource for more information.yes
granularityDefines the granularity of the query. See Granularities.yes
filterSee Filters.no
limitDefines the maximum number per historical node (parsed as int) of search results to return.no (default to 1000)
intervalsA JSON Object representing ISO-8601 Intervals. This defines the time ranges to run the query over.yes
searchDimensionsThe dimensions to run the search over. Excluding this means the search is run over all dimensions.no
querySee SearchQuerySpec.yes
sortAn object specifying how the results of the search should be sorted. Possible types here are “lexicographic” (the default sort), “alphanumeric” and “strlen”.no
contextSee Contextno

The format of the result is:

[
  {
    "timestamp": "2012-01-01T00:00:00.000Z",
    "result": [
      {
        "dimension": "dim1",
        "value": "Ke$ha",
        "count": 3
      },
      {
        "dimension": "dim2",
        "value": "Ke$haForPresident",
        "count": 1
      }
    ]
  },
  {
    "timestamp": "2012-01-02T00:00:00.000Z",
    "result": [
      {
        "dimension": "dim1",
        "value": "SomethingThatContainsKe",
        "count": 1
      },
      {
        "dimension": "dim2",
        "value": "SomethingElseThatContainsKe",
        "count": 2
      }
    ]
  }
]