Skip to content

[BUG] Escaping special characters for searches #744

Open
@lguariento

Description

@lguariento

When the input search string contains a parenthesis Lucene interprets it as an unescaped special character. For instance, searching for test) or httpclient() .

Error:

<?xml version="1.0" ?><exception><path>/db/apps/doc/modules/view.xql</path><message>exerr:ERROR Syntax error in Lucene query string: Cannot parse 'exist)': Encountered " ")" ") "" at line 1, column 5.
Was expecting one of:
    <EOF> 
    <AND> ...
    <OR> ...
    <NOT> ...
    "+" ...
    "-" ...
    <BAREOPER> ...
    "(" ...
    "*" ...
    "^" ...
    <QUOTED> ...
    <TERM> ...
    <FUZZY_SLOP> ...
    <PREFIXTERM> ...
    <WILDTERM> ...
    <REGEXPTERM> ...
    "[" ...
    "{" ...
    <NUMBER> ...
     [at line 53, column 21]
In function:
	dq:do-query(node()*, xs:string?, xs:string?) [30:30:/db/apps/doc/modules/search.xql]
	dq:query(node()*, map(*), xs:string?, xs:string, xs:string) [-1:-1:/db/apps/doc/modules/search.xql]

We should escape any special character from searches.

Followign exceptions could be useful (even used)

  • double quotes for phrase searches: "this is my search term"
  • asterisk for fuzzy searches: *
  • how about question marks: ?

The query is here.

This issue was originally posted under /website.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions