I want to access our mysql server in groovy script filter to do some query with value of some fields. Is it possible to do this?
I'm not sure whether this is possible (probably is somehow) but accessing an other datastore during the search process is a bad idea and you should avoid doing this as it will kill the search performance. I would instead perform a search in Elasticsearch with the other filter criteria and then have some post processing in your application that further filters based on the contents of your mysql tables.
Alternatively I would add the information you want to filter on in the mysql database to the documents as part of your indexing process.
thanks for the suggestion. I agree it is not a good idea to do this. The reason why I did not index the info in mysql to elasticsearch is such info is mutable. The cost to update the value in mysql is much cheap. It is painful to do this in elasticsearch
Anybody can tell more insight?
You could do it but it'll be lots slower. I'd just write it as a native
script plugin with mysql driver as the dependency.
Thank you, Nik. So I got some concrete questions. In which folder i need to put the mysql driver for groovy to import? And how to set the class path for groovy filter script? Could you help?
I'm not sure. As I said if I were to do this then I'd write a plugin. And I
wouldn't do it because it'll be super slow.
OK. Thank you.