bripkens / lucene

Node.js lib to transform: lucene query → syntax tree → lucene query
MIT License
72 stars 33 forks source link

Possible to parse escaped quotes? #38

Closed karangarg45 closed 3 years ago

karangarg45 commented 3 years ago

The original lucene lib had an issue and a known limitation related to parse the escaped quotes. https://github.com/thoward/lucene-query-parser.js/issues/1

When i try to do the same in this library, i get some unexpected result(not an error though). Is it also a limitation with this parser too?

Codesandbox example for the same https://codesandbox.io/s/busy-browser-kzykt?file=/src/index.js

bripkens commented 3 years ago

Hey @karangarg45,

in the code example you did not correctly string escape the quotes.

You use: 'keyword: "some \"random\"" ' whereas it should be 'keyword: "some \\"random\\"" ' (try executing this on the Node.js command line/browser dev tools to test this).

karangarg45 commented 3 years ago

@bripkens Thanks for the quick response. The string shared by you gives the correct output but now my output contains extra \ charcter. This is what the output looks like image

annanyearian commented 3 years ago

@karangarg45 Your output looks correct to me. The output string contains only the characters some "random".

In term: "some \"random\"" the 2 slashes and 2 outer quotation marks don't exist as part of the string. They are how the terminal/console/browser shows you the data.


"some \"random\"" === 'some "random"'