noamt / elasticsearch-grails-plugin

The revived ElasticSearch grails plugin
Based on Graeme Rocher initial stub. Note that it is still in early stage.
Other
63 stars 83 forks source link

indexing domain objects, without restarting server #80

Open mayurkarve opened 9 years ago

mayurkarve commented 9 years ago

Hi, I am deploying the grails war on a tomcat server. When I need to reindex the data, right now I restart my tomcat, which runs the following line of code from bootstrap: elasticSearchService.index(). Is there a way to reindex without needing to restart tomcat or send a request to a controller/action which invokes the line of code? Maybe there is a grails command like "grails index-elastic-server" that I don't know about. Please let me know. Thanks for all your great work. Mayur

motleycrew commented 9 years ago

Hi,

We are having similar problems. To reindex the data cleanly we have to perform following steps:-

We currently have elasticSearchService.index() in our Bootstrap.groovy

  1. Shutdown tomcat
  2. Shutdown elastic search
  3. Delete existing index manually
  4. Start elastic search
  5. Restart tomcat and wait for indexing for finish.

This causes significant downtime. Is there a way, to do indexing outside grails and reduce the amount of downtime? Thanks for the creating this plugin, it has been very useful.

Is there a grails/groovy script that we can write? So we don't have to restart tomcat everytime.

marcoscarceles commented 9 years ago

Hi, you should be able to reindex the content by invoking elasticSearchService.index() yourself. As far as I know there is no need for this to be invoked from Bootstrap. In our project we use both a quartz scheduler (to reindex content nightly) and a fixture controller that we call when needed to reindex content ad-hoc. Would that solve your problem? Also please bear in mind that by default the plugin will index the content on saves and updates With this feature enabled, unless you are modifying the data outside the grails application, there shouldn't be a need for reindexing content.

I hope that helps.

Cheers! On 20 Jan 2015 19:14, "motleycrew" notifications@github.com wrote:

Hi,

We are having similar problems. To reindex the data cleanly we have to perform following steps:-

We currently have elasticSearchService.index() in our Bootstrap.groovy

  1. Shutdown tomcat
  2. Shutdown elastic search
  3. Delete existing index manually
  4. Start elastic search
  5. Restart tomcat and wait for indexing for finish.

This causes significant downtime. Is there a way, to do indexing outside grails and reduce the amount of downtime? Thanks for the creating this plugin, it has been very useful.

Is there a grails/groovy script that we can write? So we don't have to restart tomcat everytime.

— Reply to this email directly or view it on GitHub https://github.com/noamt/elasticsearch-grails-plugin/issues/80#issuecomment-70745340 .

marcoscarceles commented 9 years ago

Hi @mayurkarve, @motleycrew,

Did that solve your issue? Is there any further help needed?

motleycrew commented 9 years ago

Hi Marco, First of all, thank you for your great work on the plugin version 0.4.0. We updated it yesterday and we did not see any merge exceptions that we usually see. Hats off! We are building a new product and our db schema changes quite often. Correspondingly, we also end up making quite a few changes to our database outside of our grails application. Therefore, we need something to trigger indexing on demand and not rely on bootstrap. I wrote a grails script which can index db it works fine when grails is installed (dev boxes). However on production we don't have grails installed and we would not like to do so.I am not sure how I can invoke grails script, when app is deployed as war on Tomcat. Any pointers will be very helpful. Cheers,Abhishek includeTargets << grailsScript("_GrailsInit") includeTargets << grailsScript("_GrailsBootstrap") includeTargets << grailsScript("_GrailsClasspath")

target(runElastic: "Run Elastic Search") { compile() depends(configureApp) appCtx.getBean("elasticSearchService").index() }

setDefaultTarget(runElastic)

Date: Fri, 30 Jan 2015 05:54:29 -0800 From: notifications@github.com To: elasticsearch-grails-plugin@noreply.github.com CC: andubey@gmail.com Subject: Re: [elasticsearch-grails-plugin] indexing domain objects, without restarting server (#80)

Hi @mayurkarve, @motleycrew,

Did that solve your issue? Is there any further help needed?

— Reply to this email directly or view it on GitHub.

                  =
peh commented 9 years ago

@motleycrew, have you tried creating an action (should be secured in some way) that calls elasticSearchService.index()?

Would be the easiest and i would say the "common" way to do it on produciton servers. Remember that this can take some time which can result in load balancers trying to do the same request on multiple appservers. Which would in the end result in multiple reindexes. So you should consider calling one appserver directly or in the created action call elasticSearchService.index() asynchronously (e.g. start a new thread).

We are using jesque for this: simply create a job that is only calling elasticSearchService.index() and either enqueue it manually or create an action which is doing this.