-
Notifications
You must be signed in to change notification settings - Fork 80
Closed
Labels
queryIssues related to the tantivy query engineIssues related to the tantivy query engine
Description
I have a query containing double quotes, e.g. a measurement in inches - '36"'. Right now I'm using tantivy.Index.query_parser(query) to parse the query. I have two questions:
- What is the default behavior of the analyzer in this case for double quotes? (can probably answer myself with a bit more digging)
- I haven't been able to find a way to parse this without hitting
SyntaxError, is this a bug?
---> 21 query = self._index.parse_query(q.query) # Search all fields
22 search_results = self._tantivy_results_to_docs(
23 self._searcher.search(query, q.limit).hits
24 )
25 return [
26 SearchResultFromSystem(
27 result=SearchResult(query=q, result=self._tantivy_doc_to_dict(doc)),
(...)
32 for idx, (score, doc) in enumerate(search_results)
33 ]
ValueError: Syntax Error: fawkes 36" blue vanity
The approaches I've tried, all of which result in the same error above:
Escape the double quote: 36\"
Double or triple escape the quote: 36\\\" or 36\\"
Encode: '36"'.encode('utf-8')
Unicode from here: "36\\u{FF02}"
Raw python string: r'36"'
Raw python string w/ escapes from above: r'36\"'...
What should I do to get Tantivy to interpret this not as a field search, but as a literal double quote?
Metadata
Metadata
Assignees
Labels
queryIssues related to the tantivy query engineIssues related to the tantivy query engine