Issues

Select view

Select search mode

 

Unable to extend NumericFieldBridge

Fixed

Description

Hi,

In the documentation (https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#numeric-field-annotation) we have the example:

Example 27. Defining a custom NumericFieldBridge for BigDecimal

By checking the class (org.hibernate.search.bridge.builtin.NumericFieldBridge), I realized that it is now an 'enum' and the constructor is private respectively.

I believe the documentation is incorrect, or a refactoring made it impossible to extend the class.

Particularly, I'm using with Elasticsearch 5.6 like this:

If it's just the documentation, I can update it. We can even add more examples, such as a custom FieldBridge to a complex enum too.

Test Cases.

TestCase with error: https://github.com/frekele/hibernate-search-elasticsearch-test-case/tree/HSEARCH-2906
Travis CI log: https://travis-ci.org/frekele/hibernate-search-elasticsearch-test-case/builds/282576064

TestCase without error: https://github.com/frekele/hibernate-search-elasticsearch-test-case/tree/HSEARCH-2906-fixed
Travis CI log: https://travis-ci.org/frekele/hibernate-search-elasticsearch-test-case/builds/282577388

Attachments

2

Details

Assignee

Reporter

Components

Affects versions

Priority

Created October 3, 2017 at 3:02 AM
Updated November 27, 2017 at 2:01 PM
Resolved November 27, 2017 at 2:01 PM

Activity

Show:

Leandro Kersting de FreitasOctober 4, 2017 at 3:06 AM

Hi,

So we let's wait to update the documentation after 6.x release.
Later I can contribute more with the updates.

Yoann RodièreOctober 3, 2017 at 8:03 AM

Hi ,

Thanks for the report! Yes, it seems we failed to update the documentation a long time ago (https://github.com/hibernate/hibernate-search/commit/46f5f5c70094265e338a76f9725dbbf10a64ad3b, while developing 5.0.0).

The current implementation of BigDecimalFieldBridge (and the one that should be in the documentation) is still in our tests, and it looks a lot like yours (though you dropped the "storeFactor"): https://github.com/hibernate/hibernate-search/blob/6dfbb22d3dc3093f6c4231a7601fc08afc5c1476/engine/src/test/java/org/hibernate/search/test/engine/numeric/BigDecimalNumericFieldBridge.java#L19-L18

If you want to submit a PR, I'll be glad to merge it. I think we should keep the changes to a minimum though, simply updating the code and stating that implementing MetadataProvidingFieldBridge is necessary so that Hibernate Search knows the field should be treated as numeric when querying/sorting. There's a lot more we could improve in the documentation, but we'll have to rewrite a big part of it in 6.0, so any improvement now would be a short-lived one.

Flag notifications