1

I am trying to set up the Apache Solr backend for searching products in Django Oscar.So I have followed the documentation provided here:https://django-oscar.readthedocs.io/en/latest/howto/how_to_setup_solr.html.

However after extracting the tar file and putting the required code in the settings.py file.I ran the command

./manage.py build_solr_schema > solr-4.7.2/example/solr/collection1/conf/schema.xml

On the console I got this output:

Save the following output to 'schema.xml' and place it in your Solr configuration directory.
--------------------------------------------------------------------------------------------

So I copied it on top of the existing code in schema.xml.Then ran java -jar start.jar and I got this error org.xml.sax.SAXParseException: Content is not allowed in prolog, so I googled it up and found an answer here ,it seems that there was an extra space inserted after I copied the output from the console to this file, so I just removed it.

Now I ran the same command java -jar start.jar and I got another error.

    3552 [coreLoadExecutor-4-thread-1] ERROR org.apache.solr.core.CoreContainer  – Unable to create core: collection1
org.apache.solr.common.SolrException: Schema Parsing Failed: unknown field 'id'. Schema file is /home/netzary/SamuelProjects/cecilia_new2/cecilia/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.<init>(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)
        at java.lang.Thread.run(Thread.java:748)
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
3561 [coreLoadExecutor-4-thread-1] ERROR org.apache.solr.core.CoreContainer  – null:org.apache.solr.common.SolrException: Unable to create core: collection1
        at org.apache.solr.core.CoreContainer.recordAndThrow(CoreContainer.java:989)
        at org.apache.solr.core.CoreContainer.create(CoreContainer.java:606)
        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)
        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/netzary/SamuelProjects/cecilia_new2/cecilia/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.<init>(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)
        ... 8 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

3564 [main] INFO  org.apache.solr.servlet.SolrDispatchFilter  – user.dir=/home/netzary/SamuelProjects/cecilia_new2/cecilia/solr-4.7.2/example
3565 [main] INFO  org.apache.solr.servlet.SolrDispatchFilter  – SolrDispatchFilter.init() done
3619 [main] INFO  org.eclipse.jetty.server.AbstractConnector  – Started SocketConnector@0.0.0.0:8983

I guess it means that there is a field named 'id' which it cannot run?I don't know how to solve this, so I need some help to make this work or are there any other steps that I might be missing?

Sammy J
  • 1,048
  • 10
  • 28
  • 3
    See https://github.com/django-oscar/django-oscar/issues/2640 - there is a schema that someone has shared there which might help. Unfortunately the schema generated by Oscar doesn't work with never versions of Solr, and it's unlikely to get fixed because the project is dropping support for Solr in the near future. – solarissmoke Aug 29 '18 at 03:20
  • Thanks for your reply @solarissmoke. I copied the schema in the link you gave, into my project and it worked.I guess oscar is moving into elasticsearch?I found the discussion (https://github.com/django-oscar/django-oscar/issues/2709). Is there a similar documentation on how to set up elasticsearch with oscar? – Sammy J Aug 29 '18 at 08:46

0 Answers0