summaryrefslogtreecommitdiff
path: root/storage/mroonga/vendor/groonga/include/groonga/token.h
blob: af5e656a305f434153534d192a4e1728e174130c (plain)
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
/* -*- c-basic-offset: 2 -*- */
/*
  Copyright(C) 2014-2016 Brazil

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License version 2.1 as published by the Free Software Foundation.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#pragma once

#ifdef __cplusplus
extern "C" {
#endif  /* __cplusplus */

/*
 * grn_tokenize_mode describes propose for tokenization.
 *
 * `GRN_TOKENIZE_GET`: Tokenize for search.
 *
 * `GRN_TOKENIZE_ADD`: Tokenize for adding token to index.
 *
 * `GRN_TOKENIZE_DELETE`: Tokenize for deleting token from index.
 *
 * @since 4.0.8
 */
typedef enum {
  GRN_TOKENIZE_GET = 0,
  GRN_TOKENIZE_ADD,
  GRN_TOKENIZE_DELETE,
  GRN_TOKENIZE_ONLY
} grn_tokenize_mode;

/*
  grn_token_mode describes propose for tokenization.

  `GRN_TOKEN_GET`: Tokenization for search.

  `GRN_TOKEN_ADD`: Tokenization for adding token to index.

  `GRN_TOKEN_DEL`: Tokenization for deleting token from index.

  @since 4.0.7
  @deprecated since 4.0.8. Use grn_tokenize_mode instead.
 */
typedef grn_tokenize_mode grn_token_mode;

#define GRN_TOKEN_GET GRN_TOKENIZE_GET
#define GRN_TOKEN_ADD GRN_TOKENIZE_ADD
#define GRN_TOKEN_DEL GRN_TOKENIZE_DELETE

/*
 * grn_token_status is a flag set for tokenizer status codes.
 * If a document or query contains no tokens, push an empty string with
 * GRN_TOKEN_LAST as a token.
 *
 * @since 4.0.8
 */
typedef unsigned int grn_token_status;

/*
 * GRN_TOKEN_CONTINUE means that the next token is not the last one.
 *
 * @since 4.0.8
 */
#define GRN_TOKEN_CONTINUE           (0)
/*
 * GRN_TOKEN_LAST means that the next token is the last one.
 *
 * @since 4.0.8
 */
#define GRN_TOKEN_LAST               (0x01L<<0)
/*
 * GRN_TOKEN_OVERLAP means that ...
 *
 * @since 4.0.8
 */
#define GRN_TOKEN_OVERLAP            (0x01L<<1)
/*
 * GRN_TOKEN_UNMATURED means that ...
 *
 * @since 4.0.8
 */
#define GRN_TOKEN_UNMATURED          (0x01L<<2)
/*
 * GRN_TOKEN_REACH_END means that ...
 *
 * @since 4.0.8
 */
#define GRN_TOKEN_REACH_END          (0x01L<<3)
/*
 * GRN_TOKEN_SKIP means that the token is skipped
 *
 * @since 4.0.8
 */
#define GRN_TOKEN_SKIP               (0x01L<<4)
/*
 * GRN_TOKEN_SKIP_WITH_POSITION means that the token and postion is skipped
 *
 * @since 4.0.8
 */
#define GRN_TOKEN_SKIP_WITH_POSITION (0x01L<<5)
/*
 * GRN_TOKEN_FORCE_PREIX that the token is used common prefix search
 *
 * @since 4.0.8
 */
#define GRN_TOKEN_FORCE_PREFIX       (0x01L<<6)

typedef struct _grn_token grn_token;

GRN_PLUGIN_EXPORT grn_obj *grn_token_get_data(grn_ctx *ctx,
                                              grn_token *token);
GRN_PLUGIN_EXPORT grn_rc grn_token_set_data(grn_ctx *ctx,
                                            grn_token *token,
                                            const char *str_ptr,
                                            int str_length);
GRN_PLUGIN_EXPORT grn_token_status grn_token_get_status(grn_ctx *ctx,
                                                        grn_token *token);
GRN_PLUGIN_EXPORT grn_rc grn_token_set_status(grn_ctx *ctx,
                                              grn_token *token,
                                              grn_token_status status);

#ifdef __cplusplus
}  /* extern "C" */
#endif  /* __cplusplus */