Navigation Menu

Skip to content

Commit

Permalink
NO_SYNTAX_ERROR: support queries starting with "~"
Browse files Browse the repository at this point in the history
GitHub: #767
  • Loading branch information
s-yata committed Oct 10, 2017
1 parent 272f324 commit d3f972b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/expr.c
Expand Up @@ -7595,12 +7595,17 @@ parse_query(grn_ctx *ctx, efs_info *q)
q->cur++;
break;
case GRN_QUERY_ADJ_NEG :
op->op = GRN_OP_ADJUST;
parse_query_accept_adjust(ctx,
q,
q->cur, 1,
GRN_EXPR_TOKEN_NEGATIVE,
-DEFAULT_WEIGHT);
if (first_token) {
parse_query_flush_pending_token(ctx, q);
parse_query_accept_string(ctx, q, q->cur, 1);
} else {
op->op = GRN_OP_ADJUST;
parse_query_accept_adjust(ctx,
q,
q->cur, 1,
GRN_EXPR_TOKEN_NEGATIVE,
-DEFAULT_WEIGHT);
}
q->cur++;
break;
case GRN_QUERY_PARENL :
Expand Down
@@ -0,0 +1,13 @@
table_create Names TABLE_PAT_KEY ShortText
[[0,0.0,0.0],true]
table_create Tokens TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
[[0,0.0,0.0],true]
column_create Tokens names_key COLUMN_INDEX|WITH_POSITION Names _key
[[0,0.0,0.0],true]
load --table Names
[
{"_key": "name (x~y)"}
]
[[0,0.0,0.0],1]
select Names --match_columns "_key" --query "~y" --query_flags ALLOW_PRAGMA|ALLOW_COLUMN|QUERY_NO_SYNTAX_ERROR
[[0,0.0,0.0],[[[1],[["_id","UInt32"],["_key","ShortText"]],[1,"name (x~y)"]]]]
@@ -0,0 +1,16 @@
table_create Names TABLE_PAT_KEY ShortText

table_create Tokens TABLE_PAT_KEY ShortText \
--default_tokenizer TokenBigram \
--normalizer NormalizerAuto
column_create Tokens names_key COLUMN_INDEX|WITH_POSITION Names _key

load --table Names
[
{"_key": "name (x~y)"}
]

select Names \
--match_columns "_key" \
--query "~y" \
--query_flags ALLOW_PRAGMA|ALLOW_COLUMN|QUERY_NO_SYNTAX_ERROR

0 comments on commit d3f972b

Please sign in to comment.