-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Elasticsearch low and high level REST clients #8290
Elasticsearch low and high level REST clients #8290
Conversation
d160efa
to
538ac17
Compare
538ac17
to
da53ae6
Compare
@gsmet the fact that a user can not easily use the high level rest client bother me a lot, I found a way to allow this without providing support for it: we can add the RestClientBuilder as a CDI bean so if someone still want to use the high level rest client he can do something like this:
WDYT |
28d9667
to
b39d064
Compare
Cool stuff. I haven't reviewed in details (expect a thorough review at some point ;)) but I have a few questions:
As for the high level client, I don't have a problem having a separate extension for it. We would need to check how it behaves with native image though. And maybe we could be a bit aggressive with exclusions (maybe it doesn't need Lucene typically). I agree exposing the builder as a CDI bean looks neat and would be useful in all cases. |
It should be possible, as CDI beans will be removed automatically, if not used we can produce them without any issue. The main issue is that hibernate-search users will start seeing an But we should be able to rename the current hidden extension to elasticsearch-core as it's not a user facing extension right ? |
As you want, it's a common feature request for database extension but I don't know of often it is for Elasticsearch |
It's either way ;) An other approach would be to propose a PR to the Elasticsearch driver to be able to create a hig level rest client from a low level one ;) |
@gsmet I think again at providing connection to multiple clusters. I would prefere to merge this PR without it and opening an Epic that list what we want to support on Elasticsearch: multi-tenant, metrics, investigation of hibernate-search-standalone or Panache, ... The idea is to build our Elasticsearch support in steps. We can then decide what will be the minimum level of support before we document it and integrate the extension inside code.quarkus.io so it becomes visible to users. |
b39d064
to
5fb6414
Compare
Added the high level client as a separate extension (didn't update the guide yet). I move the health check to the common extension to be able to use it in both, maybe we can find a way to use it with hibernate-search-elasticsearch also ;) I have an issue with a banned dependency : log4j2 is banned but the corresponding bridge from jboss-logmanager is not publushed in maven central: https://github.com/jboss-logging/log4j2-jboss-logmanager. I customize the configuration of the enforcer plugin for now but it's temporary ... |
I refactor the code to share code between the two clients. I implement more configuration options + the sniffer. I integrate the high level client inside the documentation. |
6f82a21
to
c8d920f
Compare
c8d920f
to
f50f0ca
Compare
I remove all the un-needed dependencies from lucene, I use Jdeps to know which one are needed, then I add back the one that are needed for native-image to works (see the comment inside the pom). |
f50f0ca
to
cc9f761
Compare
@gsmet I rebased on master to fix some merge issues. I would love this PR to be considered for 1.5 if it's still possible ? |
cc9f761
to
b87311d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some comments, mostly in the documentation. Didn't have the time to finish the review before going on PTO, sorry about that :/.
On a more general note, I would go with:
- quarkus-elasticsearch-rest-client-common for the existing extension
- quarkus-elasticsearch-rest-client for the low level client
- quarkus-elasticsearch-rest-high-level-client for the high level client
That way, we would be consistent with the Elasticsearch clients.
<artifactId>elasticsearch-rest-high-level-client</artifactId> | ||
<!-- We exclude all lucene libraries that are not needed --> | ||
<!-- Jdeps shows that only lucene-core and lucene-queries are needed--> | ||
<!-- Native image needs also lucene-highlighter and lucene-join --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could add substitutions to remove the need for them. I'm pretty sure they are not really useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll open a followup issue for this if it's OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
...java/io/quarkus/elasticsearch/highlevel/client/ElasticsearchRestHighLevelClientRecorder.java
Outdated
Show resolved
Hide resolved
...ient/runtime/src/main/java/io/quarkus/elasticsearch/lowlevel/client/ElasticsearchConfig.java
Outdated
Show resolved
Hide resolved
4827ff4
to
c5b832b
Compare
@gsmet I renamed the three extensions, apply your suggestions and implements most of what you ask. |
@gsmet due to the change that mandates that an extension runtime module depending on another extension mandate that the extension's deployment module also depands on another extension deployment's module, this PR needs to be re-worked. I think I must create another common module to share the code between the two clients. So I propose to rename the just renammed |
As for the split, let me some time to think about it and check the code. I'm a bit puzzled why we cannot have both the deployment of the low level client and the high level client running at the same time as one is based on the other. I will have a closer look before the end of the week. |
@gsmet I try to move all the common part to the common module and it works and it didn't crash hibernate-search that also use the common module so it appears to be safe. The only caveat is that I also move the config to the common module as both client uses the same config (but I can duplicate it). I don't know if it's an issue as hibernate-search didn't use the same configuration options, and those options are not used inside the common module. |
I don't think that's a good idea. For me, here's what it's supposed to do:
This way you don't have to do all sorts of weird things: the low level and high level extensions fully co-exist as the latter is based on the former. One interesting thing is that the javadoc Note that even if we subclass it, we should just expose it as a Does it make sense? |
cc89595
to
cc63165
Compare
@gsmet I restructure the code to reuse the rest client inside the high level one. |
@@ -1,4 +1,4 @@ | |||
# quarkus-integration-test-elasticsearch project | |||
# quarkus-integration-test-elasticsearch-rest-client project |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't you missing high-level
here and below? Not sure as GH UI is doing weird things with those files but better check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, bad copy/paste. Fixed.
cc63165
to
d562e83
Compare
I extracted part of the log4j2 fix here: #10560 as I want to backport it and I need it for a Platform related thingy. |
Superseded by #10745 . |
This PR integrates the Elasticsearch low level rest client inside Quarkus.
It creates a new extension that allows to configure a connection to Elasticsearch inside
application.properties
and inject aRestClient
.The configuration properties has the same semantics as the one from the Hibernate search extension.
This is a draft PR, some works still needs to be done around configuration and documentation.