I noticed this optional Lucene regex syntax, and wasn't sure what it's purpose was. When performing a regex query in Lucene, you can enable @
as a special character with the ANYSTRING flag, like so:
new RegexpQuery(new Term("text", "abc@"), RegExp.ANYSTRING);
Tried a few things, and it seems to behave the same as:
new RegexpQuery(new Term("text", "abc.*"));
The ElasticSearch docs note that it can be used with other optional syntax to provide an "anything except" query, such as:
new RegexpQuery(new Term("text", "ab(@&~(cd))"), RegExp.ALL);
But even this seems to work fine with .*
instead:
new RegexpQuery(new Term("text", "ab(.*&~(cd))"), RegExp.ALL);
So why does this optional @
syntax exist? Is it just an alias for .*
, or is there some subtle difference between the two that I am missing?