Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quarkus Hibernate search programmatic API #32760

Closed
mhautman opened this issue Apr 19, 2023 · 6 comments · Fixed by #35026
Closed

Quarkus Hibernate search programmatic API #32760

mhautman opened this issue Apr 19, 2023 · 6 comments · Fixed by #35026
Labels
area/hibernate-search Hibernate Search kind/enhancement New feature or request
Milestone

Comments

@mhautman
Copy link

Description

Hi,

I have a requirement where I need to be able to define a prefix for the index names. (So different environments can use the same ElasticSearch instance)

I found this is possible with hibernate-search using the programmatic API (https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#hsearch-mapping-programmaticapi), however I didn't find any support for it in Quarkus Hibernate search extension because the property to point to the mapping is missing (hibernate.search.mapping.configurer)

Could this be implemented/added? Or am I missing something?

Thanks in advance.

Regards,
Morgan

Implementation ideas

No response

@mhautman mhautman added the kind/enhancement New feature or request label Apr 19, 2023
@quarkus-bot quarkus-bot bot added the area/hibernate-search Hibernate Search label Apr 19, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 19, 2023

/cc @gsmet (hibernate-search), @yrodiere (hibernate-search)

@yrodiere
Copy link
Member

yrodiere commented Apr 20, 2023

Hey,

I have a requirement where I need to be able to define a prefix for the index names. (So different environments can use the same ElasticSearch instance)

You may want to use a custom layout strategy. Just implement IndexLayoutStrategy and annotate with @SearchExtension.

See also quarkus.hibernate-search-orm.elasticsearch.layout.strategy.

I found this is possible with hibernate-search using the programmatic API
Could this be implemented/added? Or am I missing something?

It could be implemented, it's just that nobody had any use for it so far, so it wasn't deemed a priority. If anyone is interested in providing a pull request, I'd suggest they have a look at how support for analysis configurers is implemented in Quarkus and take inspiration from that. A few pointers:

There will be limitations though, in particular Quarkus may not be able to auto-detect all classes that need reflection because it usually does so at build time (based on annotations), and programmatic mapping happens later (on static init). So, when using programmatic mapping, developers may need to register some of their mapped classes for reflection manually.

@mhautman
Copy link
Author

Hey Yoann,

I Implemented it indeed with a custom layout strategy and it works like a charm, thanks for the pointer!

@mhautman mhautman reopened this Apr 21, 2023
@yrodiere yrodiere reopened this Apr 21, 2023
@yrodiere
Copy link
Member

Nice, thanks for the feedback. Let's leave the issue open as programmatic mapping still isn't available in Quarkus at the moment :)

@yrodiere
Copy link
Member

yrodiere commented Jul 3, 2023

FWIW, regarding this:

There will be limitations though, in particular Quarkus may not be able to auto-detect all classes that need reflection because it usually does so at build time (based on annotations), and programmatic mapping happens later (on static init). So, when using programmatic mapping, developers may need to register some of their mapped classes for reflection manually.

It seems GraalVM is able to detect reflection needs based on java.lang.reflect.Constructor/java.lang.reflect.Method/java.lang.reflect.Field instances in the heap at the end of static init. So we may not need to register extra classes for reflection after all; programmatic mapping may only need a configuration property + @SearchExtension support to work properly. We'll need (native) tests to check that, though.

@cthiebault
Copy link

Hey Yoann,

I Implemented it indeed with a custom layout strategy and it works like a charm, thanks for the pointer!

Hello @mhautman

I'm trying to achieve the same thing but I have some issue to retrieve the configurable prefix and use it in my IndexLayoutStrategy custom implementation. See #41384

How did you manage to do it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-search Hibernate Search kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants