Groonga
Loading...
Searching...
No Matches
expr.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2009-2017 Brazil
3 Copyright (C) 2019-2025 Sutou Kouhei <kou@clear-code.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
20#pragma once
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26typedef uint32_t grn_expr_flags;
27
28#define GRN_EXPR_SYNTAX_QUERY (0x00)
29#define GRN_EXPR_SYNTAX_SCRIPT (0x01)
30#define GRN_EXPR_SYNTAX_OUTPUT_COLUMNS (0x20)
31#define GRN_EXPR_SYNTAX_ADJUSTER (0x40)
32#define GRN_EXPR_SYNTAX_SORT_KEYS (0x100)
33/* Deprecated since Groonga 11.0.2. Use GRN_EXPR_SYNTAX_SORT_KEYS instead. */
34#define GRN_EXPR_SYNTAX_GROUP_KEYS GRN_EXPR_SYNTAX_SORT_KEYS
35#define GRN_EXPR_SYNTAX_OPTIONS (0x200)
36#define GRN_EXPR_ALLOW_PRAGMA (0x02)
37#define GRN_EXPR_ALLOW_COLUMN (0x04)
38#define GRN_EXPR_ALLOW_UPDATE (0x08)
39#define GRN_EXPR_ALLOW_LEADING_NOT (0x10)
40#define GRN_EXPR_QUERY_NO_SYNTAX_ERROR (0x80)
41#define GRN_EXPR_DISABLE_PREFIX_SEARCH (0x400)
42#define GRN_EXPR_DISABLE_AND_NOT (0x800)
43
45grn_expr_create(grn_ctx *ctx, const char *name, unsigned int name_size);
50 grn_obj *expr,
51 const char *name,
52 unsigned int name_size);
55 grn_obj *expr,
56 const char *name,
57 unsigned int name_size);
59grn_expr_get_var_by_offset(grn_ctx *ctx, grn_obj *expr, unsigned int offset);
62
63GRN_API void
65
68 grn_ctx *ctx, grn_obj *expr, grn_obj *obj, grn_operator op, int nargs);
71 grn_ctx *ctx, grn_obj *expr, grn_obj *obj, grn_operator op, int nargs);
74 grn_obj *expr,
75 const char *str,
76 unsigned int str_size,
77 grn_operator op,
78 int nargs);
79/* Deprecated since Groonga 11.0.1. Use grn_expr_append_const_int32() instead.
80 */
83 grn_ctx *ctx, grn_obj *expr, int value, grn_operator op, int nargs);
86 grn_ctx *ctx, grn_obj *expr, int32_t value, grn_operator op, int nargs);
89 grn_ctx *ctx, grn_obj *expr, uint32_t value, grn_operator op, int nargs);
92 grn_ctx *ctx, grn_obj *expr, bool value, grn_operator op, int nargs);
95 grn_ctx *ctx, grn_obj *expr, float value, grn_operator op, int nargs);
98 grn_ctx *ctx, grn_obj *expr, double value, grn_operator op, int nargs);
100grn_expr_append_op(grn_ctx *ctx, grn_obj *expr, grn_operator op, int nargs);
101
139
163 const char *query,
164 int query_size,
165 const char *target_characters,
166 char escape_character,
167 grn_obj *escaped_query);
185 const char *query,
186 int query_size,
187 grn_obj *escaped_query);
190 const char *query,
191 int query_size,
192 grn_expr_flags flags,
193 grn_obj *expander,
194 grn_obj *expanded_query);
197 const char *query,
198 int query_size,
199 grn_expr_flags flags,
200 grn_obj *term_column,
201 grn_obj *expanded_term_column,
202 grn_obj *expanded_query);
203
211grn_expr_exec(grn_ctx *ctx, grn_obj *expr, int nargs);
212
214grn_expr_alloc(grn_ctx *ctx, grn_obj *expr, grn_id domain, unsigned char flags);
215
216#define GRN_EXPR_CREATE_FOR_QUERY(ctx, table, expr, var) \
217 do { \
218 if (((expr) = grn_expr_create((ctx), NULL, 0)) && \
219 ((var) = grn_expr_add_var((ctx), (expr), NULL, 0))) { \
220 GRN_RECORD_INIT((var), 0, grn_obj_id((ctx), (table))); \
221 } else { \
222 (var) = NULL; \
223 } \
224 } while (0)
225
228 grn_obj *expr,
229 const char *str,
230 unsigned int str_size,
231 grn_obj *default_column,
232 grn_operator default_mode,
233 grn_operator default_op,
234 grn_expr_flags flags);
235uint32_t
237
240 grn_obj *expr,
241 int flags,
242 unsigned int width,
243 unsigned int max_results,
244 unsigned int n_tags,
245 const char **opentags,
246 unsigned int *opentag_lens,
247 const char **closetags,
248 unsigned int *closetag_lens,
249 grn_snip_mapping *mapping);
252 grn_obj *expr,
253 grn_obj *snip,
254 unsigned int n_tags,
255 const char **opentags,
256 unsigned int *opentag_lens,
257 const char **closetags,
258 unsigned int *closetag_lens);
259
260GRN_API unsigned int
262
265 grn_obj *expr,
266 const char *prefix,
267 int prefix_len);
268GRN_API const char *
270
275
280
281#ifdef __cplusplus
282}
283#endif
GRN_API grn_rc grn_expr_clear_vars(grn_ctx *ctx, grn_obj *expr)
GRN_API grn_rc grn_expr_dump_plan(grn_ctx *ctx, grn_obj *expr, grn_obj *buffer)
GRN_API grn_obj * grn_expr_rewrite(grn_ctx *ctx, grn_obj *expr)
GRN_API grn_obj * grn_expr_snip(grn_ctx *ctx, grn_obj *expr, int flags, unsigned int width, unsigned int max_results, unsigned int n_tags, const char **opentags, unsigned int *opentag_lens, const char **closetags, unsigned int *closetag_lens, grn_snip_mapping *mapping)
GRN_API grn_obj * grn_expr_get_condition(grn_ctx *ctx, grn_obj *expr)
GRN_API grn_rc grn_expr_syntax_expand_query_by_table(grn_ctx *ctx, const char *query, int query_size, grn_expr_flags flags, grn_obj *term_column, grn_obj *expanded_term_column, grn_obj *expanded_query)
GRN_API grn_rc grn_expr_set_parent(grn_ctx *ctx, grn_obj *expr, grn_obj *parent)
GRN_API grn_rc grn_expr_close(grn_ctx *ctx, grn_obj *expr)
GRN_API grn_obj * grn_expr_append_const_int(grn_ctx *ctx, grn_obj *expr, int value, grn_operator op, int nargs)
GRN_API grn_rc grn_expr_get_keywords(grn_ctx *ctx, grn_obj *expr, grn_obj *keywords)
Extract keywords from an expression.
GRN_API unsigned int grn_expr_estimate_size(grn_ctx *ctx, grn_obj *expr)
GRN_API grn_obj * grn_expr_append_const_float32(grn_ctx *ctx, grn_obj *expr, float value, grn_operator op, int nargs)
uint32_t grn_expr_flags
Definition expr.h:26
GRN_API grn_obj * grn_expr_append_const_int32(grn_ctx *ctx, grn_obj *expr, int32_t value, grn_operator op, int nargs)
GRN_API grn_obj * grn_expr_create(grn_ctx *ctx, const char *name, unsigned int name_size)
GRN_API grn_rc grn_expr_syntax_escape_query(grn_ctx *ctx, const char *query, int query_size, grn_obj *escaped_query)
Escape special characters in a query.
GRN_API grn_obj * grn_expr_get_var_by_offset(grn_ctx *ctx, grn_obj *expr, unsigned int offset)
GRN_API grn_rc grn_expr_syntax_expand_query(grn_ctx *ctx, const char *query, int query_size, grn_expr_flags flags, grn_obj *expander, grn_obj *expanded_query)
uint32_t grn_expr_get_n_codes(grn_ctx *ctx, grn_obj *expr)
GRN_API grn_obj * grn_expr_exec(grn_ctx *ctx, grn_obj *expr, int nargs)
GRN_API const char * grn_expr_get_query_log_tag_prefix(grn_ctx *ctx, grn_obj *expr)
GRN_API void grn_expr_take_obj(grn_ctx *ctx, grn_obj *expr, grn_obj *obj)
GRN_API grn_rc grn_expr_set_condition(grn_ctx *ctx, grn_obj *expr, grn_obj *condition)
GRN_API grn_rc grn_expr_syntax_escape(grn_ctx *ctx, const char *query, int query_size, const char *target_characters, char escape_character, grn_obj *escaped_query)
Escape target characters in a query by a specified escape character.
GRN_API grn_rc grn_expr_compile(grn_ctx *ctx, grn_obj *expr)
GRN_API grn_obj * grn_expr_append_const_bool(grn_ctx *ctx, grn_obj *expr, bool value, grn_operator op, int nargs)
GRN_API grn_obj * grn_expr_get_parent(grn_ctx *ctx, grn_obj *expr)
GRN_API grn_obj * grn_expr_append_const_uint32(grn_ctx *ctx, grn_obj *expr, uint32_t value, grn_operator op, int nargs)
GRN_API grn_obj * grn_expr_get_var(grn_ctx *ctx, grn_obj *expr, const char *name, unsigned int name_size)
GRN_API grn_obj * grn_expr_alloc(grn_ctx *ctx, grn_obj *expr, grn_id domain, unsigned char flags)
GRN_API grn_obj * grn_expr_add_var(grn_ctx *ctx, grn_obj *expr, const char *name, unsigned int name_size)
GRN_API grn_obj * grn_expr_append_const_float(grn_ctx *ctx, grn_obj *expr, double value, grn_operator op, int nargs)
GRN_API grn_obj * grn_expr_append_const(grn_ctx *ctx, grn_obj *expr, grn_obj *obj, grn_operator op, int nargs)
GRN_API grn_rc grn_expr_set_query_log_tag_prefix(grn_ctx *ctx, grn_obj *expr, const char *prefix, int prefix_len)
GRN_API grn_rc grn_expr_snip_add_conditions(grn_ctx *ctx, grn_obj *expr, grn_obj *snip, unsigned int n_tags, const char **opentags, unsigned int *opentag_lens, const char **closetags, unsigned int *closetag_lens)
GRN_API grn_rc grn_expr_parse(grn_ctx *ctx, grn_obj *expr, const char *str, unsigned int str_size, grn_obj *default_column, grn_operator default_mode, grn_operator default_op, grn_expr_flags flags)
GRN_API grn_rc grn_expr_append_op(grn_ctx *ctx, grn_obj *expr, grn_operator op, int nargs)
GRN_API grn_obj * grn_expr_append_obj(grn_ctx *ctx, grn_obj *expr, grn_obj *obj, grn_operator op, int nargs)
GRN_API grn_obj * grn_expr_append_const_str(grn_ctx *ctx, grn_obj *expr, const char *str, unsigned int str_size, grn_operator op, int nargs)
grn_rc
Definition groonga.h:61
uint32_t grn_id
Definition groonga.h:44
#define GRN_API
Definition groonga.h:39
grn_operator
Definition groonga.h:1149
Definition groonga.h:351
Definition groonga.h:919
Definition groonga.h:2300