Groonga
Loading...
Searching...
No Matches
expr.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define GRN_EXPR_SYNTAX_QUERY   (0x00)
 
#define GRN_EXPR_SYNTAX_SCRIPT   (0x01)
 
#define GRN_EXPR_SYNTAX_OUTPUT_COLUMNS   (0x20)
 
#define GRN_EXPR_SYNTAX_ADJUSTER   (0x40)
 
#define GRN_EXPR_SYNTAX_SORT_KEYS   (0x100)
 
#define GRN_EXPR_SYNTAX_GROUP_KEYS   GRN_EXPR_SYNTAX_SORT_KEYS
 
#define GRN_EXPR_SYNTAX_OPTIONS   (0x200)
 
#define GRN_EXPR_ALLOW_PRAGMA   (0x02)
 
#define GRN_EXPR_ALLOW_COLUMN   (0x04)
 
#define GRN_EXPR_ALLOW_UPDATE   (0x08)
 
#define GRN_EXPR_ALLOW_LEADING_NOT   (0x10)
 
#define GRN_EXPR_QUERY_NO_SYNTAX_ERROR   (0x80)
 
#define GRN_EXPR_DISABLE_PREFIX_SEARCH   (0x400)
 
#define GRN_EXPR_DISABLE_AND_NOT   (0x800)
 
#define GRN_EXPR_CREATE_FOR_QUERY(ctx, table, expr, var)
 

Typedefs

typedef uint32_t grn_expr_flags
 

Functions

GRN_API grn_objgrn_expr_create (grn_ctx *ctx, const char *name, unsigned int name_size)
 
GRN_API grn_rc grn_expr_close (grn_ctx *ctx, grn_obj *expr)
 
GRN_API grn_objgrn_expr_add_var (grn_ctx *ctx, grn_obj *expr, const char *name, unsigned int name_size)
 
GRN_API grn_objgrn_expr_get_var (grn_ctx *ctx, grn_obj *expr, const char *name, unsigned int name_size)
 
GRN_API grn_objgrn_expr_get_var_by_offset (grn_ctx *ctx, grn_obj *expr, unsigned int offset)
 
GRN_API grn_rc grn_expr_clear_vars (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_objgrn_expr_append_obj (grn_ctx *ctx, grn_obj *expr, grn_obj *obj, grn_operator op, int nargs)
 
GRN_API grn_objgrn_expr_append_const (grn_ctx *ctx, grn_obj *expr, grn_obj *obj, grn_operator op, int nargs)
 
GRN_API grn_objgrn_expr_append_const_str (grn_ctx *ctx, grn_obj *expr, const char *str, unsigned int str_size, grn_operator op, int nargs)
 
GRN_API grn_objgrn_expr_append_const_int (grn_ctx *ctx, grn_obj *expr, int value, grn_operator op, int nargs)
 
GRN_API grn_objgrn_expr_append_const_int32 (grn_ctx *ctx, grn_obj *expr, int32_t value, grn_operator op, int nargs)
 
GRN_API grn_objgrn_expr_append_const_uint32 (grn_ctx *ctx, grn_obj *expr, uint32_t value, grn_operator op, int nargs)
 
GRN_API grn_objgrn_expr_append_const_bool (grn_ctx *ctx, grn_obj *expr, bool value, grn_operator op, int nargs)
 
GRN_API grn_objgrn_expr_append_const_float32 (grn_ctx *ctx, grn_obj *expr, float value, grn_operator op, int nargs)
 
GRN_API grn_objgrn_expr_append_const_float (grn_ctx *ctx, grn_obj *expr, double value, grn_operator op, int nargs)
 
GRN_API grn_rc grn_expr_append_op (grn_ctx *ctx, grn_obj *expr, 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 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_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_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)
 
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_compile (grn_ctx *ctx, grn_obj *expr)
 
GRN_API grn_objgrn_expr_rewrite (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_objgrn_expr_exec (grn_ctx *ctx, grn_obj *expr, int nargs)
 
GRN_API grn_objgrn_expr_alloc (grn_ctx *ctx, grn_obj *expr, grn_id domain, unsigned char flags)
 
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)
 
uint32_t grn_expr_get_n_codes (grn_ctx *ctx, grn_obj *expr)
 
GRN_API grn_objgrn_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_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 unsigned int grn_expr_estimate_size (grn_ctx *ctx, grn_obj *expr)
 
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 const char * grn_expr_get_query_log_tag_prefix (grn_ctx *ctx, grn_obj *expr)
 
GRN_API grn_rc grn_expr_set_parent (grn_ctx *ctx, grn_obj *expr, grn_obj *parent)
 
GRN_API grn_objgrn_expr_get_parent (grn_ctx *ctx, grn_obj *expr)
 
GRN_API grn_rc grn_expr_set_condition (grn_ctx *ctx, grn_obj *expr, grn_obj *condition)
 
GRN_API grn_objgrn_expr_get_condition (grn_ctx *ctx, grn_obj *expr)
 

Macro Definition Documentation

◆ GRN_EXPR_ALLOW_COLUMN

#define GRN_EXPR_ALLOW_COLUMN   (0x04)

◆ GRN_EXPR_ALLOW_LEADING_NOT

#define GRN_EXPR_ALLOW_LEADING_NOT   (0x10)

◆ GRN_EXPR_ALLOW_PRAGMA

#define GRN_EXPR_ALLOW_PRAGMA   (0x02)

◆ GRN_EXPR_ALLOW_UPDATE

#define GRN_EXPR_ALLOW_UPDATE   (0x08)

◆ GRN_EXPR_CREATE_FOR_QUERY

#define GRN_EXPR_CREATE_FOR_QUERY (   ctx,
  table,
  expr,
  var 
)
Value:
do { \
if (((expr) = grn_expr_create((ctx), NULL, 0)) && \
((var) = grn_expr_add_var((ctx), (expr), NULL, 0))) { \
GRN_RECORD_INIT((var), 0, grn_obj_id((ctx), (table))); \
} else { \
(var) = NULL; \
} \
} while (0)
GRN_API grn_obj * grn_expr_create(grn_ctx *ctx, const char *name, unsigned int name_size)
GRN_API grn_obj * grn_expr_add_var(grn_ctx *ctx, grn_obj *expr, const char *name, unsigned int name_size)
GRN_API grn_id grn_obj_id(grn_ctx *ctx, grn_obj *obj)
Return the ID of an object.

◆ GRN_EXPR_DISABLE_AND_NOT

#define GRN_EXPR_DISABLE_AND_NOT   (0x800)

◆ GRN_EXPR_DISABLE_PREFIX_SEARCH

#define GRN_EXPR_DISABLE_PREFIX_SEARCH   (0x400)

◆ GRN_EXPR_QUERY_NO_SYNTAX_ERROR

#define GRN_EXPR_QUERY_NO_SYNTAX_ERROR   (0x80)

◆ GRN_EXPR_SYNTAX_ADJUSTER

#define GRN_EXPR_SYNTAX_ADJUSTER   (0x40)

◆ GRN_EXPR_SYNTAX_GROUP_KEYS

#define GRN_EXPR_SYNTAX_GROUP_KEYS   GRN_EXPR_SYNTAX_SORT_KEYS

◆ GRN_EXPR_SYNTAX_OPTIONS

#define GRN_EXPR_SYNTAX_OPTIONS   (0x200)

◆ GRN_EXPR_SYNTAX_OUTPUT_COLUMNS

#define GRN_EXPR_SYNTAX_OUTPUT_COLUMNS   (0x20)

◆ GRN_EXPR_SYNTAX_QUERY

#define GRN_EXPR_SYNTAX_QUERY   (0x00)

◆ GRN_EXPR_SYNTAX_SCRIPT

#define GRN_EXPR_SYNTAX_SCRIPT   (0x01)

◆ GRN_EXPR_SYNTAX_SORT_KEYS

#define GRN_EXPR_SYNTAX_SORT_KEYS   (0x100)

Typedef Documentation

◆ grn_expr_flags

typedef uint32_t grn_expr_flags

Function Documentation

◆ grn_expr_add_var()

GRN_API grn_obj * grn_expr_add_var ( grn_ctx ctx,
grn_obj expr,
const char *  name,
unsigned int  name_size 
)

◆ grn_expr_alloc()

GRN_API grn_obj * grn_expr_alloc ( grn_ctx ctx,
grn_obj expr,
grn_id  domain,
unsigned char  flags 
)

◆ grn_expr_append_const()

GRN_API grn_obj * grn_expr_append_const ( grn_ctx ctx,
grn_obj expr,
grn_obj obj,
grn_operator  op,
int  nargs 
)

◆ grn_expr_append_const_bool()

GRN_API grn_obj * grn_expr_append_const_bool ( grn_ctx ctx,
grn_obj expr,
bool  value,
grn_operator  op,
int  nargs 
)

◆ grn_expr_append_const_float()

GRN_API grn_obj * grn_expr_append_const_float ( grn_ctx ctx,
grn_obj expr,
double  value,
grn_operator  op,
int  nargs 
)

◆ grn_expr_append_const_float32()

GRN_API grn_obj * grn_expr_append_const_float32 ( grn_ctx ctx,
grn_obj expr,
float  value,
grn_operator  op,
int  nargs 
)

◆ grn_expr_append_const_int()

GRN_API grn_obj * grn_expr_append_const_int ( grn_ctx ctx,
grn_obj expr,
int  value,
grn_operator  op,
int  nargs 
)

◆ grn_expr_append_const_int32()

GRN_API grn_obj * grn_expr_append_const_int32 ( grn_ctx ctx,
grn_obj expr,
int32_t  value,
grn_operator  op,
int  nargs 
)

◆ grn_expr_append_const_str()

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_expr_append_const_uint32()

GRN_API grn_obj * grn_expr_append_const_uint32 ( grn_ctx ctx,
grn_obj expr,
uint32_t  value,
grn_operator  op,
int  nargs 
)

◆ grn_expr_append_obj()

GRN_API grn_obj * grn_expr_append_obj ( grn_ctx ctx,
grn_obj expr,
grn_obj obj,
grn_operator  op,
int  nargs 
)

◆ grn_expr_append_op()

GRN_API grn_rc grn_expr_append_op ( grn_ctx ctx,
grn_obj expr,
grn_operator  op,
int  nargs 
)

◆ grn_expr_clear_vars()

GRN_API grn_rc grn_expr_clear_vars ( grn_ctx ctx,
grn_obj expr 
)

◆ grn_expr_close()

GRN_API grn_rc grn_expr_close ( grn_ctx ctx,
grn_obj expr 
)

◆ grn_expr_compile()

GRN_API grn_rc grn_expr_compile ( grn_ctx ctx,
grn_obj expr 
)

◆ grn_expr_create()

GRN_API grn_obj * grn_expr_create ( grn_ctx ctx,
const char *  name,
unsigned int  name_size 
)

◆ grn_expr_dump_plan()

GRN_API grn_rc grn_expr_dump_plan ( grn_ctx ctx,
grn_obj expr,
grn_obj buffer 
)

◆ grn_expr_estimate_size()

GRN_API unsigned int grn_expr_estimate_size ( grn_ctx ctx,
grn_obj expr 
)

◆ grn_expr_exec()

GRN_API grn_obj * grn_expr_exec ( grn_ctx ctx,
grn_obj expr,
int  nargs 
)

◆ grn_expr_get_condition()

GRN_API grn_obj * grn_expr_get_condition ( grn_ctx ctx,
grn_obj expr 
)

◆ grn_expr_get_keywords()

GRN_API grn_rc grn_expr_get_keywords ( grn_ctx ctx,
grn_obj expr,
grn_obj keywords 
)

Extract keywords from an expression.

For example usage:

grn_obj keywords;
// You don't need to unlink keyword because it is owned by expr.
grn_expr_get_keywords(ctx, expr, &keywords);
{
size_t i, n_keywords;
n_keywords = grn_vector_size(ctx, &keywords);
for (i = 0; i < n_keywords; i++) {
const char *keyword_content;
size_t keyword_size;
keyword_size = grn_vector_get_element(ctx,
&keywords,
i,
&keyword_content,
NULL,
NULL);
// Use keyword_content and keyword_size.
}
}
GRN_OBJ_FIN(ctx, &keywords);
GRN_API grn_rc grn_expr_get_keywords(grn_ctx *ctx, grn_obj *expr, grn_obj *keywords)
Extract keywords from an expression.
#define GRN_OBJ_VECTOR
Definition groonga.h:2734
#define GRN_OBJ_FIN(ctx, obj)
Definition groonga.h:958
#define GRN_TEXT_INIT(obj, flags)
Definition groonga.h:2750
Definition groonga.h:919
GRN_API uint32_t grn_vector_get_element(grn_ctx *ctx, grn_obj *vector, uint32_t offset, const char **str, uint32_t *weight, grn_id *domain)
GRN_API uint32_t grn_vector_size(grn_ctx *ctx, grn_obj *vector)
Parameters
ctxThe context object.
exprThe expression object from which keywords will be extracted.
keywordsThe keywords container where the extracted keywords will be be stored. Each extracted keyword's domain is GRN_DB_TEXT.
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error.

◆ grn_expr_get_n_codes()

uint32_t grn_expr_get_n_codes ( grn_ctx ctx,
grn_obj expr 
)

◆ grn_expr_get_parent()

GRN_API grn_obj * grn_expr_get_parent ( grn_ctx ctx,
grn_obj expr 
)

◆ grn_expr_get_query_log_tag_prefix()

GRN_API const char * grn_expr_get_query_log_tag_prefix ( grn_ctx ctx,
grn_obj expr 
)

◆ grn_expr_get_var()

GRN_API grn_obj * grn_expr_get_var ( grn_ctx ctx,
grn_obj expr,
const char *  name,
unsigned int  name_size 
)

◆ grn_expr_get_var_by_offset()

GRN_API grn_obj * grn_expr_get_var_by_offset ( grn_ctx ctx,
grn_obj expr,
unsigned int  offset 
)

◆ grn_expr_parse()

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_expr_rewrite()

GRN_API grn_obj * grn_expr_rewrite ( grn_ctx ctx,
grn_obj expr 
)

◆ grn_expr_set_condition()

GRN_API grn_rc grn_expr_set_condition ( grn_ctx ctx,
grn_obj expr,
grn_obj condition 
)

◆ grn_expr_set_parent()

GRN_API grn_rc grn_expr_set_parent ( grn_ctx ctx,
grn_obj expr,
grn_obj parent 
)

◆ grn_expr_set_query_log_tag_prefix()

GRN_API grn_rc grn_expr_set_query_log_tag_prefix ( grn_ctx ctx,
grn_obj expr,
const char *  prefix,
int  prefix_len 
)

◆ grn_expr_snip()

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_expr_snip_add_conditions()

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_expr_syntax_escape()

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.

Note
For general query syntax escaping, it is recommended to use grn_expr_syntax_escape_query instead.
Parameters
ctxThe context object. Its encoding must match that of the input query.
queryThe input query to be escaped.
query_sizeThe byte size of query. A value of -1 indicates that the query is null-terminated.
target_charactersA null-terminated string containing the characters to be escaped. For example, "+-><~*()\"\\:" is used for query syntax.
escape_characterThe character to use for escaping characters found in target_characters. For example, "\\" (backslash) is used.
escaped_queryThe buffer where the escaped query is stored.
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error.

◆ grn_expr_syntax_escape_query()

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.

Parameters
ctxThe context object. Its encoding must match that of the input query. It is used for allocating buffer for escaped_query.
queryThe input query to be escaped.
query_sizeThe byte size of query. A value of -1 indicates that the query is null-terminated.
escaped_queryThe buffer where the escaped query is stored.
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error.
See also
https://groonga.org/docs/reference/grn_expr/query_syntax.html

◆ grn_expr_syntax_expand_query()

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 
)

◆ grn_expr_syntax_expand_query_by_table()

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_expr_take_obj()

GRN_API void grn_expr_take_obj ( grn_ctx ctx,
grn_obj expr,
grn_obj obj 
)