HibernateSearchPhoneNumberBridge.ktValueBridge<String?, String> that transforms a phone number field into a rich searchable string by combining the original value, a digits-only normalized form, and a formatted extraction. Enables searches like "+49 30 123456", "4930123456", and "030/123456" to all match the same record.class HibernateSearchPhoneNumberBridge : ValueBridge<String?, String>
String (the raw phone number from the entity)String (the composite string stored in the search index)toIndexedValue()override fun toIndexedValue(number: String?, context: ValueBridgeToIndexedValueContext): String
Produces a space-separated composite string containing three representations:
"+49 30 123456-78")StringHelper.removeNonDigits(number) (e.g. "493012345678")NumberHelper.extractPhonenumber(number)Result example: "+49 30 123456-78 493012345678 030/12345678"
Hibernate Search's default analyzer tokenizes on whitespace, making all three forms independently searchable.
""), not null. This prevents NPEs in the search index writer.Phone numbers are notoriously difficult to search because users enter them in various formats: international (+49 30 123456), local (030/123456), compact (4930123456), or with punctuation. By indexing multiple normalized forms side-by-side in a single field, any user-entered search format can match.
The onlyDigits approach handles the most general case (any format reduces to the same digit sequence), while the extractPhonenumber approach preserves local formatting conventions for exact-match scenarios.
868d6abb7 2025 -> 2026 63081666f Source file headers: 2024-> 2025. 7798dac85 Migration stuff in progress... (all tests of all packages: OK). 974d70bec Migration stuff in progress... 4f5a458c9 Migration stuff in progress... c04fb0d51 Migration stuff in progress... b6092df09 Copyright 2023 -> 2024 ab45d51fa Copyright 2001-2022 -> 2001-2023. 5f7ef41b8 Copyright 2021 -> 2022 ceb63e8a1 Source code header: (C) 2001-2021. 7c79f1922 Copyright of source header -> 2020. 000ca723d Remove pointless boolean expressions (business) dd5ca38ac CopyRight of all java file-header updated or created. 9ebb88522 Initial commit