Navigation Menu

Skip to content

Commit

Permalink
bq: support OR
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 6, 2012
1 parent 3f6a469 commit bd3f1e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/bq-translator.js
Expand Up @@ -240,6 +240,12 @@ BooleanQueryTranslator.prototype = {
tokens.push("&&");
value = "";
}
} else if (character == "|") {
if (value.length > 0) {
tokens.push(this.translateExpressionValueStringKeyword(field, value));
tokens.push("||");
value = "";
}
} else if (character == "\\") {
this.offset++;
character = this.query[this.offset];
Expand Down
4 changes: 4 additions & 0 deletions test/bq-translator.test.js
Expand Up @@ -113,6 +113,10 @@ suite('BoolanQueryTranslator', function() {
"'keyword1+keyword2' 'other keyword'",
"'keyword1+keyword2'".length,
"field @ \"keyword1\" && field @ \"keyword2\"");
testExpression("value only: stirng: or",
"'keyword1|keyword2' 'other keyword'",
"'keyword1|keyword2'".length,
"field @ \"keyword1\" || field @ \"keyword2\"");
testExpression("value only: stirng: phrase",
"'\"keyword1 keyword2\"' 'other keyword'",
"'\"keyword1 keyword2\"'".length,
Expand Down

0 comments on commit bd3f1e3

Please sign in to comment.