Is there any way to dynamically update data index without restarting EmbeddedSolrServer in solrj?

user2428568

my simple code is

I am run this code in java WebServlet

                solrDir = config.getServletContext().getRealPath("/lotiya");
                container = new CoreContainer(solrDir);
                container.load();
                server = new EmbeddedSolrServer(container, "collection1");
                solrParams = new ModifiableSolrParams();

                solrParams = new ModifiableSolrParams();
                solrParams.add(CommonParams.Q, "*:*");

            //solrParams.set("qt", "/dataimport");
            //solrParams.set("command", "full-import");
            //solrParams.set("command", "reload-config");

            solrParams.set("wt", "json");

            QueryResponse queryResponse = server.query(solrParams);

            for (SolrDocument document : queryResponse.getResults()) {
              System.out.println(document);
            }

at first time , when dataimport is run well. Exception is come when run second time because of "write.lock" in indexes that I know one solution is that restart the server and check but every time this technique not possible. so, Is there any method to reindex.

Exception code like...

org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: Index locked for write for core collection1
    at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:827)
    at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:110)
    at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:90)
    at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:301)
    at solrjj.TestSolr.doGet(TestSolr.java:71)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.solr.common.SolrException: Index locked for write for core collection1
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:844)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:630)
    at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:562)
    at org.apache.solr.core.CoreContainer.create(CoreContainer.java:597)
    at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:258)
    at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:250)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    ... 3 more
Caused by: org.apache.lucene.store.LockObtainFailedException: Index locked for write for core collection1
    at org.apache.solr.core.SolrCore.initIndex(SolrCore.java:496)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:761)
    ... 11 more
Pratik Solanki

I think you are using Servlet. Try this following code with init() method of servlet.

    container = new CoreContainer(solrDir);
    container.load();
    server = new EmbeddedSolrServer(container, "collection1");
    solrParams = new ModifiableSolrParams();

Reason: When ever servlet is load initialized, every time it creates container object and server object which is already using collection1 so that why is raises error of write.lock

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is there any way to update PrimeFaces data table without updating the table headers?

From Dev

Update listbox without restarting program?

From Dev

How to index data in a specific shard using solrj

From Java

Dynamically changing log level without restarting the application

From Dev

Is there a way to update Primefaces form without losing data in it?

From Dev

A way to prevent Windows Update from restarting the computer?

From Dev

Spring Boot, update frontend without restarting the application

From Dev

Spring Boot - Update ResourceHandlerRegistry without restarting app

From Dev

Is there a way to update the TLS certificates in a net/http server without any downtime?

From Dev

So the add-on builder has died. Any way to test an add-on without restarting FF every time?

From Dev

Better way to dynamically update tile data on Commodore 64

From Dev

Is there any way to get Google Desktop Search to index Microsoft OneNote data?

From Dev

Any efficient way for parallel filtering on list of index in data.frame?

From Dev

Any way to read data from an iCloud store without the iCloud entitlement?

From Dev

Is there any way to pass checkbox data without using a submit button?

From Dev

class file for org.apache.solr.client.solrj.embedded.EmbeddedSolrServer not found

From Dev

update a div data dynamically

From Dev

Update data dynamically

From Dev

update the data dynamically in AngularJS

From Dev

Is there any way in Yii2 to dynamically change URL without reloading? a part from pjax

From Dev

How to update server's content without restarting it? (node.js)

From Dev

Update the sys.config file without restarting node

From Dev

IntelliJ Idea 15 - How to "update resources" without restarting server?

From Dev

Update camel-sap cache without restarting the whole instance

From Dev

How can i update flask templates without restarting the uwsgi instance?

From Dev

Is there a way to kill all forked threads in a GHCi session without restarting it?

From Dev

Is there a way to open Swift Playground without restarting Xcode 6?

From Dev

Is there a way to "resource" by bash_profile without restarting terminal?

From Dev

Any way to call a constructor (or any function/method) from data types without going through two templated functions?

Related Related

  1. 1

    Is there any way to update PrimeFaces data table without updating the table headers?

  2. 2

    Update listbox without restarting program?

  3. 3

    How to index data in a specific shard using solrj

  4. 4

    Dynamically changing log level without restarting the application

  5. 5

    Is there a way to update Primefaces form without losing data in it?

  6. 6

    A way to prevent Windows Update from restarting the computer?

  7. 7

    Spring Boot, update frontend without restarting the application

  8. 8

    Spring Boot - Update ResourceHandlerRegistry without restarting app

  9. 9

    Is there a way to update the TLS certificates in a net/http server without any downtime?

  10. 10

    So the add-on builder has died. Any way to test an add-on without restarting FF every time?

  11. 11

    Better way to dynamically update tile data on Commodore 64

  12. 12

    Is there any way to get Google Desktop Search to index Microsoft OneNote data?

  13. 13

    Any efficient way for parallel filtering on list of index in data.frame?

  14. 14

    Any way to read data from an iCloud store without the iCloud entitlement?

  15. 15

    Is there any way to pass checkbox data without using a submit button?

  16. 16

    class file for org.apache.solr.client.solrj.embedded.EmbeddedSolrServer not found

  17. 17

    update a div data dynamically

  18. 18

    Update data dynamically

  19. 19

    update the data dynamically in AngularJS

  20. 20

    Is there any way in Yii2 to dynamically change URL without reloading? a part from pjax

  21. 21

    How to update server's content without restarting it? (node.js)

  22. 22

    Update the sys.config file without restarting node

  23. 23

    IntelliJ Idea 15 - How to "update resources" without restarting server?

  24. 24

    Update camel-sap cache without restarting the whole instance

  25. 25

    How can i update flask templates without restarting the uwsgi instance?

  26. 26

    Is there a way to kill all forked threads in a GHCi session without restarting it?

  27. 27

    Is there a way to open Swift Playground without restarting Xcode 6?

  28. 28

    Is there a way to "resource" by bash_profile without restarting terminal?

  29. 29

    Any way to call a constructor (or any function/method) from data types without going through two templated functions?

HotTag

Archive