Closed jakecadams closed 6 years ago
Most likely an issue with the grammar. The grammar is far from correct. Feel free to contribute a fix :)
Looked into this again, the query you defined is not valid according to official lucene query parser (the one written in Java):
Exception in thread "main" org.apache.lucene.queryparser.classic.ParseException: Cannot parse 'foo~bar:"hello"': Encountered " ":" ": "" at line 1, column 7.
Was expecting one of:
<EOF>
<AND> ...
<OR> ...
<NOT> ...
"+" ...
"-" ...
<BAREOPER> ...
"(" ...
"*" ...
"^" ...
<QUOTED> ...
<TERM> ...
<PREFIXTERM> ...
<WILDTERM> ...
<REGEXPTERM> ...
"[" ...
"{" ...
<NUMBER> ...
What would be valid, is an escaped tilde in the keyword, i.e. foo\~bar:"hello"
Which unfortunately is also misunderstood by this library :/
> require('.').parse('foo\~bar:"hello"')
{ left:
{ field: '<implicit>',
term: 'foo',
quoted: false,
similarity: 0.5,
boost: null,
prefix: null },
operator: '<implicit>',
right:
{ field: 'bar',
term: 'hello',
quoted: true,
proximity: null,
boost: null,
prefix: null } }
> require('.').parse('foo\\~bar:"hello"')
{ left:
{ field: '<implicit>',
term: 'foo\\',
quoted: false,
similarity: 0.5,
boost: null,
prefix: null },
operator: '<implicit>',
right:
{ field: 'bar',
term: 'hello',
quoted: true,
proximity: null,
boost: null,
prefix: null } }
>
Escaping strategy has been changed with release 2.0.0 such that this issue no longer applies. In addition, this module now provides helpers for easy escaping/unescaping.
https://runkit.com/embed/kx7k2fbprecw
I'm having issues escaping the tilde on the field. It seems to work for some other special chars. Any suggestions here?