0
votes

I'm following the django documentation to integrate solr with django-Oscar.I'm getting the following error when trying to rebuild the index.How can I fix this issue?

$python3 manage.py rebuild_index --noinput

Removing all documents from your index because you said so.

    Failed to clear Solr index: Solr responded with an error (HTTP 500): [Reason: Error 500 {msg=SolrCore 'collection1' is not available due to init failure: Schema Parsing Failed: unknown field 'id'. Schema file is /project/solr-4.7.2/example/solr/collection1/schema.xml,trace=org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: Schema Parsing Failed: unknown field 'id'. Schema file is /project/solr-4.7.2/example/solr/collection1/schema.xml
        at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:827)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:305)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:205)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
        at org.eclipse.jetty.server.Server.handle(Server.java:368)
        at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
        at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
        at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:953)
        at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1014)
        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)
        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
        at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
        at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: org.apache.solr.common.SolrException: Schema Parsing Failed: unknown field 'id'. Schema file is /project/solr-4.7.2/example/solr/collection1/schema.xml
        at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:618)
        at org.apache.solr.schema.IndexSchema.(IndexSchema.java:166)
        at org.apache.solr.schema.IndexSchemaFactory.create(IndexSchemaFactory.java:55)
        at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69)
        at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:559)
        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(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        ... 1 more
    Caused by: java.lang.RuntimeException: unknown field 'id'
        at org.apache.solr.schema.IndexSchema.getIndexedField(IndexSchema.java:340)
        at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:536)
        ... 13 more
    ,code=500}]
    Traceback (most recent call last):
      File "/home/asanka/.local/lib/python3.5/site-packages/haystack/backends/solr_backend.py", line 105, in clear
        self.conn.delete(q='*:*', commit=commit)
      File "/home/asanka/.local/lib/python3.5/site-packages/pysolr.py", line 948, in delete
        return self._update(m, commit=commit, softCommit=softCommit, waitFlush=waitFlush, waitSearcher=waitSearcher, handler=handler)
      File "/home/asanka/.local/lib/python3.5/site-packages/pysolr.py", line 488, in _update
        return self._send_request('post', path, message, {'Content-type': 'text/xml; charset=utf-8'})
      File "/home/asanka/.local/lib/python3.5/site-packages/pysolr.py", line 403, in _send_request
        raise SolrError(error_message % (resp.status_code, solr_message))
    pysolr.SolrError: Solr responded with an error (HTTP 500): [Reason: Error 500 {msg=SolrCore 'collection1' is not available due to init failure: Schema Parsing Failed: unknown field 'id'. Schema file is /home/asanka/Music/devBranch/dailyDeal_v3/main_app/solr-4.7.2/example/solr/collection1/schema.xml,trace=org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: Schema Parsing Failed: unknown field 'id'. Schema file is /home/asanka/Music/devBranch/dailyDeal_v3/main_app/solr-4.7.2/example/solr/collection1/schema.xml
        at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:827)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:305)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:205)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
        at org.eclipse.jetty.server.Server.handle(Server.java:368)
        at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
        at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
        at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:953)
        at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1014)
        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)
        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
        at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
        at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: org.apache.solr.common.SolrException: Schema Parsing Failed: unknown field 'id'. Schema file is /home/asanka/Music/devBranch/dailyDeal_v3/main_app/solr-4.7.2/example/solr/collection1/schema.xml
        at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:618)
        at org.apache.solr.schema.IndexSchema.(IndexSchema.java:166)
        at org.apache.solr.schema.IndexSchemaFactory.create(IndexSchemaFactory.java:55)
        at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69)
        at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:559)
        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(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        ... 1 more
    Caused by: java.lang.RuntimeException: unknown field 'id'
        at org.apache.solr.schema.IndexSchema.getIndexedField(IndexSchema.java:340)
        at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:536)
        ... 13 more
    ,code=500}]

All documents removed.

1
Did you build the solr schema before running this command? It looks like you're using the wrong schema.solarissmoke
yes I did build and replace the schema as the django-oscar documentation.using : python3 manage.py build_solr_schema > solr-4.7.2/example/solr/collection1/conf/schema.xmlAsankaJ
My best guess is that the place you are putting the schema file is not where solr is looking for it. You need to check where the schema needs to be put for your version of solr, and write it to that location. The documentation is giving an example that is probably out of date with regard to the location of the schema file.solarissmoke
Schema.xml is placed on the correct path but it seems like the created schema using build_solr_schema is invalid. i tried building the schema with the oscar sandbox, its giving the same invalid schema.AsankaJ

1 Answers

0
votes

I had a similar issue. Upon inspecting the solr schema (conf/schema.xml) file I found that <field name="id"> line was repeated (not exactly duplicate, but was definitely repetitive for same name argument).

I deleted the 2nd instance of <field name="id"> and the issue was resolved.

I eventually upgraded solr to 6.6.3 along with latest haystack and the build_schema works correctly now.