Skip to content

Commit

Permalink
Allow quoted terms within a range expression
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtilford-sc committed Mar 9, 2021
1 parent 5dd1d6c commit 9bb56c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 2 additions & 4 deletions lib/lucene.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,8 @@ rterm_char


ranged_term
= term:rterm_char+
{
return term.join('');
}
= term:rterm_char+ { return term.join(''); }
/ term:quoted_term

unquoted_term
= term:term_char+
Expand Down
7 changes: 4 additions & 3 deletions lib/queryParser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions test/queryParser_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,13 @@ describe('queryParser', () => {
expect(results['left']['term_max']).to.equal('2017-11-18T04:28:11.999Z');
expect(results['left']['inclusive']).to.equal('right');
});

it('parses a quoted term in a range expression', () => {
var results = lucene.parse('date:["3/daysAgo" TO Today]');
expect(results['left']['field']).to.equal('date');
expect(results['left']['term_min']).to.equal('3/daysAgo');
expect(results['left']['term_max']).to.equal('Today');
});
});

describe('Lucene Query syntax documentation examples', () => {
Expand Down

0 comments on commit 9bb56c3

Please sign in to comment.