Skip to content

Parser silently removes invalid input for conjunction operators #19

@thoward

Description

@thoward

As reported in issue #11, the parser currently will drop some invalid input for conjunction operators.

Problem Example:
Given this user input:

foo:bar OR NOT baz:qux

The parser outputs:

{
   "left": {
      "field": "foo",
      "term": "bar",
      "similarity": null,
      "boost": null,
      "prefix": null
   },
   "operator": "OR",
   "right": {
      "field": "baz",
      "term": "qux",
      "similarity": null,
      "boost": null,
      "prefix": null
   }
}

Note that the operator property is a single string value. The Lucene Query Syntax only supports a single operator for each left/operator/right expression phrase. Inputting two operators is invalid syntax.

The library should detect this and produce an error instead of silently removing the invalid syntax. This behaviour should be parameterized and opt-in so that it does not cause a breaking change. The error should indicate where in the input the error was detected and what class of parsing error was found, in a structured manner, so that the application code may correctly report this to the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions