Fixes https://github.com/spring-projects/spring-ai/issues/1316 as discussed in the issue, also updates the documentation to better explain the various index initialization possibilities.
Added user-agent
header to the elasticsearch client configuration. This is what we at Elastic will use to keep track of the usage of Spring AI, so that we can see statistics in the Elastic Cloud metrics, better understand the needs of Spring users and contribute more to the project.
Comment From: sobychacko
Looks good. Squashed the commits and merged upstream. Thanks!
Comment From: l-trotta
I forgot to add a unit test I wrote :') can I create another PR?
Comment From: sobychacko
@l-trotta, of course!
Comment From: l-trotta
here it is, thank you!
Comment From: sobychacko
@l-trotta When you added the user-agent
header, is there a reason you didn't do it on the RestClient
dIrectly? Also, we are considering adding this header across all the vector stores, and I was wondering how you tested this for Elasticsearch. Thanks!
Comment From: l-trotta
@sobychacko the RestClient would usually be the place where to put headers, but it this case its configuration is either: - up to the user when creating the bean - up to spring-boot when using autoconfigure
So the only way to add a header is to use the override that we have in the high level client. I tested it by checking our internal monitoring tool where requests are saved and catalogued, so not with a simple Elasticsearch instance (and noticed that I actually set it wrong, here's the fix ^^").
About other vector stores, I'd probably check whether they use user-agent as a relevant header and if possible prepend spring-ai
to the original value, or rebuilt it like I did in the new PR.