Skip to content
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

Unknown item type Phrase in LuceneCheck #95

Open
SleepyMorpheus opened this issue Mar 27, 2023 · 0 comments
Open

Unknown item type Phrase in LuceneCheck #95

SleepyMorpheus opened this issue Mar 27, 2023 · 0 comments

Comments

@SleepyMorpheus
Copy link

Hi,
When using the LuceneCheck with the following query f:"Foo Bar" I expect the check to return no error because this is (as far as I can tell) allowed in the lucene query language. I use the following code below to test this.

from .parser import parser
from .check import LuceneCheck
from .tree import SearchField, Phrase

query = (SearchField("f", Phrase('"Foo Bar"')))
check = LuceneCheck()
print(check.errors(query))

But against my expectations I get the following error.

 ['Unknown item type Phrase : "Foo Bar"']

After checking the check.py file, it appears to me that no check_phrase function is present in the LuceneCheck class which leads to the phrase object not being accepted. I'm not really sure if this is intended behavior or how to fix it but following code snippet might solve the problem

   def check_phrase(self, item, parents):
        if not item.value.endswith('"') or not item.value.startswith('"'):
            yield "Phrase value must start and end with double quote"

Any recommendations or ideas about how to fix it? Or am I doing something wrong?

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