Quote:
BTW, I'm surprised it's more performant to use annotations then to use the hibernate.search.analyzer property.
No sorry for my rushed explanation, that's not what I meant to say. Reading an annotation is indeed and "expensive" operation, and a property should do better, but I'm referring to the resulting implementation: we read annotations only once, and the Analyzer is reused at runtime for each query and each time a document is indexed, so
how we define an analyzer is not a performance issue, but
how a defined analyzer performs is critical for performance.
The way you coded the custom analyzer is what I'm saying is not optimal, as it will create a new StandardTokenizer, a new StandardFilter, a LowerCaseFilter and an ASCIIFoldingFilter at each invocation while these components are safe to be reused. So you could write a custom analyzer functionally equivalent to the one you posted but reusing the components, but that makes the code way more complex hence my recommendation to let the framework do the dirty work.