forked from instaclustr/cassandra-lucene-index
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extended-search-examples.cql
203 lines (180 loc) · 8.11 KB
/
extended-search-examples.cql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
USE test;
-- Refresh index
SELECT * FROM test.users
WHERE expr(users_index, '{ refresh : true}');
-- Boolean queries
SELECT * FROM test.users
WHERE expr(users_index, '{ query : {
type : "boolean",
must : [{type : "wildcard", field : "name", value : "*_2"},
{type : "wildcard", field : "food", value : "tu*"}]}}');
SELECT * FROM test.users
WHERE expr(users_index, '{ query : {
type : "boolean",
not : [{type : "wildcard", field : "name", value : "*_2"}],
must : [{type : "wildcard", field : "food", value : "tu*"}]}}');
SELECT * FROM test.users
WHERE expr(users_index, '{ query : {
type : "boolean",
should : [{type : "wildcard", field : "name", value : "*_2"},
{type : "wildcard", field : "food", value : "tu*"}]}}');
-- Contains queries
SELECT * FROM test.users
WHERE expr(users_index, '{ filter : {
type : "contains",
field : "name",
values : ["Alicia","mancha"]}}');
SELECT * FROM test.users
WHERE expr(users_index, '{ filter : {
type : "contains",
field : "date",
values : ["2014/01/01", "2014/01/02", "2014/01/03"]}}');
-- Date Range queries
SELECT * FROM test.users
WHERE expr(users_index, '{filter : {
type : "date_range",
field : "duration",
from : "2014/01/01",
to : "2014/12/31",
operation : "intersects"}}');
SELECT * FROM test.users
WHERE expr(users_index, '{filter : {
type : "date_range",
field : "duration",
from : "2014/06/01",
to : "2014/06/02",
operation : "contains"}}');
SELECT * FROM test.users
WHERE expr(users_index, '{filter : {
type : "date_range",
field : "duration",
from : "2014/01/01",
to : "2014/12/31",
operation : "is_within"}}');
-- Fuzzy queries
SELECT * FROM test.users
WHERE expr(users_index, '{query : {
type : "fuzzy",
field : "phrase",
value : "puma",
max_edits : 1 }}');
SELECT * FROM test.users
WHERE expr(users_index, '{filter : { type : "fuzzy",
field : "phrase",
value : "puma",
max_edits : 1,
prefix_length : 2 }}');
-- Geo bbox queries
SELECT * FROM test.users
WHERE expr(users_index, '{filter : { type : "geo_bbox",
field : "place",
min_latitude : -90.0,
max_latitude : 90.0,
min_longitude : -180.0,
max_longitude : 180.0 }}');
SELECT * FROM test.users
WHERE expr(users_index, '{filter : { type : "geo_bbox",
field : "place",
min_latitude : -90.0,
max_latitude : 90.0,
min_longitude : 0.0,
max_longitude : 10.0 }}');
SELECT * FROM test.users
WHERE expr(users_index, '{filter : { type : "geo_bbox",
field : "place",
min_latitude : 0.0,
max_latitude : 10.0,
min_longitude : -180.0,
max_longitude : 180.0 }}');
-- Geo distance queries
SELECT * FROM test.users
WHERE expr(users_index, '{filter : { type : "geo_distance",
field : "place",
latitude : 40.225479,
longitude : -3.999278,
max_distance : "1km"}}');
SELECT * FROM test.users
WHERE expr(users_index, '{filter : { type : "geo_distance",
field : "place",
latitude : 40.225479,
longitude : -3.999278,
max_distance : "10yd" ,
min_distance : "1yd" }}');
-- Match queries
SELECT * FROM test.users
WHERE expr(users_index, '{query : {
type : "match",
field : "name",
value : "Alicia" }}');
SELECT * FROM test.users
WHERE expr(users_index, '{query : {
type : "match",
field : "phrase",
value : "mancha" }}');
SELECT * FROM test.users
WHERE expr(users_index, '{query : {
type : "match",
field : "date",
value : "2014/01/01" }}');
-- Match all queries
SELECT * FROM test.users
WHERE expr(users_index, '{filter : { type : "all" }}');
-- Phrase queries
SELECT * FROM test.users
WHERE expr(users_index, '{query : {
type : "phrase",
field : "phrase",
value : "camisa manchada" }}');
SELECT * FROM test.users
WHERE expr(users_index, '{query : {
type : "phrase",
field : "phrase",
value : "mancha camisa",
slop : 2 }}');
-- Prefix queries
SELECT * FROM test.users
WHERE expr(users_index, '{query : {
type : "prefix",
field : "phrase",
value : "lu" }}');
-- Range queries
SELECT * FROM test.users
WHERE expr(users_index, '{query : {
type : "range",
field : "age",
lower : 1,
include_lower : true }}');
SELECT * FROM test.users
WHERE expr(users_index, '{query : {
type : "range",
field : "age",
upper : 0,
include_upper : true }}');
SELECT * FROM test.users
WHERE expr(users_index, '{query : {
type : "range",
field : "age",
lower : -1,
upper : 1,
include_lower : true,
include_upper : true }}');
SELECT * FROM test.users
WHERE expr(users_index, '{query : {
type : "range",
field : "date",
lower : "2014/01/01",
upper : "2014/01/02",
include_lower : true,
include_upper : true }}');
-- Regexp queries
SELECT * FROM test.users
WHERE expr(users_index, '{query : {
type : "regexp",
field : "name",
value : "([J][aeiou]){2}.*" }}');
-- Wildcard queries
SELECT * FROM test.users
WHERE expr(users_index, '{query : {
type : "wildcard",
field : "food",
value : "tu*" }}');