DESCRIBE statement provides the information about the index (or table in RDBM terminology). In Sensei, the index name is optional because when a Sensei client talks to one Sensei broker, only one index is accessible on this broker. Essentially, the index name in a DESCRIBE statement is ignored.
Example Statement:
DESCRIBE cars;
Results:
+------------+------------+---------+-----------+-------------+---------+ | facet_name | facet_type | runtime | column | column_type | depends | +------------+------------+---------+-----------+-------------+---------+ | category | simple | false | category | string | [] | | groupid | simple | false | groupid | long | [] | | city | path | false | city | string | [] | | color | simple | false | color | string | [] | | tags | multi | false | tags | string | [] | | price | range | false | price | float | [] | | makemodel | path | false | makemodel | string | [] | | mileage | range | false | mileage | int | [] | | year | range | false | year | int | [] | +------------+------------+---------+-----------+-------------+---------+
The select list in a SELECT statement can simply be a
*
, which means all columns are
selected.
If the select list is not a *
, each
item, often called a column, in the select
list is either a facet name or a field name in the index. If a
column is unknown to Sensei server, then <NOT
FOUND>
is displayed in the results.
Just like the index name in a DESCRIBE statement is optional, the FROM clause in a SELECT statement is also optional.
The WHERE clause, if given, specifies the search condition or conditions that documents must satisfy to be selected. Each condition is a Boolean expression consisting of one or more predicates. Current the following predicates are supported in BQL:
IN predicate
This predicate is used to specify the values of one column in search results. For example:
color IN ("red", "blue")
category IN ("sedan", "compact")
age in (10, 20, 30)
CONTAINS ALL predicate
This predicate is used to specify that a multi-value column has to contain all the values. For example:
tags CONTAINS ALL ("cool", "hybrid") EXCEPT("favorite")
Equal predicate
This predicate is used to specify a single value that a column needs to contain. For example:
color = "red"
Not equal predicate
This predicate is used to specify a single value that a column cannot contain. For example:
color <> "red"
Query predicate
This is used to do full text search on the internal contents column. All Lucene query syntax is supported. For example:
QUERY IS "hybrid AND (cool or moon-roof)"
Range predicate
This predicate is used to specify a value range for a range facet. For example:
year > 1999
year <= 2002
price < 17500
time >= "2011-10-20 15:30:00"
time < "2011/12/31 10:00:00"
BETWEEN predicate
This predicate is used to specify both the lower and upper bounds for a range facet at the same time. For example:
year BETWEEN 1995 AND 2000
Note that, when a BETWEEN predicate is used, both lower and upper bounds are included in the range selection.
Time predicate
This predicate is used on a column that contains time stamp values (and the column should be a range facet too). This is useful to search documents that are indexed in real-time. For example:
time IN LAST 2 hours 10 mins 30 secs 100 msecs
time SINCE 2 weeks AGO
time BEFORE 2 weeks AGO
time AFTER "2011-10-20 15:30:00"
MATCH AGAINST predicate
This predicate is used to perform full text searches on one or more columns that have a string data type. When more than one columns are given in the predicate, then any column in the list that contains specified searched string would make a document satisfy this condition. For example:
MATCH(color) AGAINST("bl*")
All cars that have a "black" or "blue" color would satisfy this predicate.
MATCH(category) AGAINST("*van")
All cars in the category of "van" or "mini-van" would satisfy this predicate.
MATCH(color, category) AGAINST("*ac*")
A car with a "black" or "blue" color, or with a category of "compact" would satisfy this condition.
LIKE predicate
This is a predicate to do wildcard text match. Two
wildcards are supported: %
and
_
. Wildcard %
matches
zero or more characters, while _
matches
exactly one character. For example:
color LIKE "bl%"
All cars that have a "black" or "blue" color would satisfy this predicate.
color LIKE "bl__"
All cars with a "blue" color would satisfy this condition, but the cars with a "black" color would not.
Note that wildcards %
and
_
, not Lucene's *
and ?
are used in BQL. This is mainly
to make BQL more compatible with SQL. However, if
*
or ?
is used, it
is also accepted.