[hibernate-dev] [!] Changing the Faceting API in Hibernate Search

Steve Ebersole steve at hibernate.org
Fri May 1 14:57:55 EDT 2015

So here is what I did.  I think this is the best compromise, short of us
hand crafting the keywords for each and every one of our Dialects...

1) I added this method to Dialect:

 * Hook into auto-quoting of identifiers that are deemed to be keywords.
By default we
 * return all of the following here:<ul>
 *     <li>all keywords as defined by ANSI SQL:2003 specification</li>
 *     <li>all "extra" keywords reported by the JDBC driver </li>
 *     <li>all extra Dialect keywords</li>
 * </ul>
 * NOTE: The code that ultimately consumes these and uses them stores them
in a case-insensitive
 * Set, so case here does not matter.
 * @see org.hibernate.engine.jdbc.env.spi.AnsiSqlKeywords#sql2003()
 * @see java.sql.DatabaseMetaData#getSQLKeywords()
 * @see #getKeywords()
public Set<String> determineKeywordsForAutoQuoting(Set<String>
databaseMetadataReportedKeywords) {
final Set<String> keywords = new HashSet<String>();
keywords.addAll( AnsiSqlKeywords.INSTANCE.sql2003() );
keywords.addAll( databaseMetadataReportedKeywords );
keywords.addAll( getKeywords() );
return keywords;

2) Changed up JdbcEnvironment to use this method rather than just calling

3) Deprecated Dialect#getKeywords

On Fri, May 1, 2015 at 10:56 AM, Sanne Grinovero <sanne at hibernate.org>

> Hi all,
> Hardy completed the Faceting re-work in Hibernate Search to use the
> much improved implementation from recent versions of Lucene, and we'd
> like to merge his work now making these improvements available to
> users of Hibernate Search 5.2.0+
> There is a catch: while the API to create a Faceting Query is
> unchanged and nicely backwards compatible, you'll now be required to
> explicitly sign up the fields which you want to be "facetable" using a
> new annotation: @Facet
> The default for an indexed property is that faceting is disabled, so
> people already using faceting will have to adjust their mapping, and
> rebuild the indexes accordingly.
> Unfortunately you won't notice the problem at compile time - and we
> can't validate for it at boot time - but you'll get a reasonable
> explanation in the exception when attempting to create a faceting
> query.
> There are many benefits to the new approach, so please bear with me
> for applying such a non-backwards compatible patch in a minor release:
> we won't break this rule often, nor are we lacking great reasons to
> proceed.
> For details see:
>  - https://github.com/hibernate/hibernate-search/pull/821
> Thanks,
> Sanne
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev

More information about the hibernate-dev mailing list