-
Notifications
You must be signed in to change notification settings - Fork 138
/
query.clj
217 lines (156 loc) · 6.21 KB
/
query.clj
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
(ns clojurewerkz.elastisch.query
(:refer-clojure :exclude [range])
(:require [clojurewerkz.elastisch.utils :as utils]))
(defn term
"Term Query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/term-query.html"
[key values & { :as options }]
(merge { (if (coll? values) :terms :term) (hash-map key values) }
options))
(defn range
"Range Query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/range-query.html"
[key & { :as options}]
{:range (hash-map key options) })
(defn text
"Text Query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html"
[query & { :as options}]
{:text { :message (merge { :query query } options) } })
(defn bool
"Boolean Query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html"
[& { :as options}]
{:bool options})
(defn boosting
"Boosting Query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/boosting-query.html"
[& { :as options}]
{:boosting options})
(defn ids
"IDs Query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/ids-query.html"
[type ids]
{:ids { :type type :values ids }})
(defn custom-score
"Custom Score Query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/custom-score-query.html"
[& {:as options}]
{:custom_score options})
(defn constant-score
"Constant Score Query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/constant-score-query.html"
[& {:as options}]
{:constant_score options})
(defn dis-max
"Dis Max Query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/dis-max-query.html"
[& {:as options}]
{:dis_max options})
(defn prefix
"Prefix query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/prefix-query.html"
[& {:as options}]
{:prefix options})
(defn field
"Field query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/field-query.html"
[& {:as options}]
{:field options})
(defn filtered
"Filtered query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/filtered-query.html"
[& {:as options}]
{:filtered options})
(defn fuzzy-like-this
"FLT (fuzzy like this) query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/flt-query.html"
[& {:as options}]
{:fuzzy_like_this options})
(defn fuzzy-like-this-field
"FLT (fuzzy like this) query for a single field
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/flt-field-query.html"
[& {:as options}]
{:fuzzy_like_this_field options})
(defn fuzzy
"Fuzzy or Levenshtein (edit distance) query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/fuzzy-query.html"
[& {:as options}]
{:fuzzy options})
(defn match-all
"Match All query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/match-all-query.html"
([]
{:match_all {}})
([& {:as options}]
{:match_all options}))
(defn mlt
"MLT (More Like This) query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/mlt-query.html"
[& {:as options}]
{:more_like_this options})
(defn mlt-field
"MLT (More Like This) query that works for a single field
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/mlt-field-query.html"
[& {:as options}]
{:more_like_this_field options})
(defn query-string
"Query String query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query.html"
[& {:as options}]
{:query_string options})
(defn span-first
"Span First query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/span-first-query.html"
[& {:as options}]
{:span_first options})
(defn span-near
"Span Near query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/span-near-query.html"
[& {:as options}]
{:span_near options})
(defn span-not
"Span Not query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/span-not-query.html"
[& {:as options}]
{:span_not options})
(defn span-or
"Span Or query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/span-or-query.html"
[& {:as options}]
{:span_or options})
(defn span-term
"Span Term query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/span-term-query.html"
[& {:as options}]
{:span_term options})
(defn wildcard
"Wildcard query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/wildcard-query.html"
[& {:as options}]
{:wildcard options})
(defn indices
"Indices query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/indices-query.html"
[& {:as options}]
{:indices options})
(defn has-child
"Has Child query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/has-child-query.html"
[& {:as options}]
{:has_child options})
(defn custom-filters-score
"Custom Filters Score query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html"
[& {:as options}]
{:custom_filters_score options})
(defn top-children
"Top children query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/top-children-query.html"
[& {:as options}]
{:top_children options})
(defn nested
"Nested document query
For more information, please refer to http://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html"
[& {:as options}]
{:nested options})