Skip to content

What is valid Tantivy Syntax? #2637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sky-cake opened this issue May 16, 2025 · 1 comment
Open

What is valid Tantivy Syntax? #2637

sky-cake opened this issue May 16, 2025 · 1 comment

Comments

@sky-cake
Copy link

I've consulted https://docs.rs/tantivy/latest/tantivy/query/struct.QueryParser.html, and it lists some valid search options, but it doesn't explain what the "syntax boundaries" are.

I don't know how to avoid SyntaxErrors when searching with,

{
   'occur': 'must',
   'normal': {
     'ctx': f'{fieldname}:{query}',
    },
}
  1. invalid query: SyntaxError("comment:https://website.org")
  2. invalid query: SyntaxError("comment:\nwords")
  3. Syntax errors with when query begins with -. Beginning with + is ok.
  4. + 2 does not search records containing + 2. Instead it looks for records with 2.
  5. I cannot escape characters like + or - with \.
  6. All non-alphanumeric characters seem to be ignored in my searches.

So stripping non-alphanumerics from the front and end of strings isn't gonna work. I don't know what to do with user input.

@sky-cake sky-cake changed the title What is valid Tantivity Syntax? What is valid Tantivy Syntax? May 16, 2025
@sky-cake
Copy link
Author

More cases which help demonstrate how a solution isn't as trivial as adding " around user search term(s).

Fail:

  1. devices usb-c adapter""
  2. https://wiki.installgentoo.com
  3. following:
  4. >>>
  5. ">>>"
  6. \>\>\> # this gives "invalid query: AllButQueryForbidden"
  7. ">>>" # ^
  8. "devices usb-c adapter" ""

Success:

  1. devices usb-c adapter" "
  2. "https://wiki.installgentoo.com"
  3. "following:"
  4. 2021-08-22
  5. "devices usb-c adapter" " "

Success but no results (when matching documents exist):

  1. ".\n"
  2. ...
  3. \.\.\.
  4. "..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant