Please consider that maybe your expectations are incorrect.
No it should not. It should match documents that contain a word starting with FLAT. You used a WhitespaceTokenizer, so a word is defined as a sequence of non-whitespace characters. Thus you will get all documents that contain FLAT at the beginning followed by non-whitespace characters, or a whitespace followed by FLAT followed by non-whitespace characters.
As it should, considering your configuration.
You seem to be implementing some kind of parser and a custom query language. I donât really understand what youâre trying to achieve, so I suggest you start with simpleQueryString instead. Do this, without trying to pre-process the string.
@yrodiere Please give me a suitable solution for this. How can i make my wildcard work like so that it will give me the documents starting from FLAT only if someone searches like FLAT*
The main problem is that wildcard queries ignore analysis completely. It is probably what brought you here: when a user searches for foo.* , the wildcard query will not apply analysis and thus will not drop the traling dot ( . ). It will then look for documents containing foo. (with a trailing dot), and wonât find anything since your analyzer dropped all the dots at indexing time.