jurismarches/luqum

Unknown item type Phrase during LuceneCheck

SleepyMorpheus opened this issue · 1 comments

Hi,
When running the script below, i expect the LuceneCheck to report no error as the query is (as far as I can tell) supported by the lucene standard.

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

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

But I am presented with the following error

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

I couldn't find any check_phrase function in the LueceneCheck class in the check.py file. Is this intended or how could this be fixed? My guess would be to add something like the following to allow phrases but I'm really not sure about this. Any recommendations or ideas?

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"

whoops, duplicated