Integrating ElasticSearch with Django-Oscar

1,103 views
Skip to first unread message

PANKAJ GOYAL

unread,
Aug 11, 2016, 3:26:21 AM8/11/16
to django-oscar
I have integrated ElasticSearch with my shop-app doing proper HAYSTACK settings but I left OSCAR_SEARCH_FACETS blank.
I am not able to decode this example. Can anyone help me on this? I could not find detailed document about it.
I am willing to do -
1) SearchBox with suggestions in dropdown
2) Filters
3) Sorting

To my understanding, all these are possible to achieve using django-oscar.

Pasting the following example in my settings.py gives me ERRORS -

OSCAR_SEARCH_FACETS = {
    'fields': OrderedDict([
        ('product_class', {'name': _('Type'), 'field': 'product_class'}),
        ('rating', {'name': _('Rating'), 'field': 'rating'}),
    ]),
    'queries': OrderedDict([
        ('price_range',
         {
             'name': _('Price range'),
             'field': 'price',
             'queries': [
                 # This is a list of (name, query) tuples where the name will
                 # be displayed on the front-end.
                 (_('0 to 20'), u'[0 TO 20]'),
                 (_('20 to 40'), u'[20 TO 40]'),
                 (_('40 to 60'), u'[40 TO 60]'),
                 (_('60+'), u'[60 TO *]'),
             ]
         }),
    ]),
}

arthu...@studio-automatique.com

unread,
Aug 15, 2016, 2:22:06 AM8/15/16
to django-oscar
Elasticsearch is not currently fully supported by Oscar, in my experience. You may have to write a custom search backend to support it. I have only been able to use Solr 4 successfully with Oscar. Thats also partly due to Django Haystack not supporting Solr 5+ yet.

YusufSalahAdDin

unread,
Aug 15, 2016, 3:19:50 AM8/15/16
to django-oscar
Man, but with the lastest version, 2.5.0 is supouse that we can work with sorl 6.1.0.

But my problem is that i don't know how setup sorl for django-oscar properly, The documentatio is oudated and i haven't idea what have i do.

I make this issue in repository, but without answers.

The problem with elasticsearch is that the newest versions deprecate facets, see this issue.

Arthur Case

unread,
Aug 15, 2016, 3:29:12 AM8/15/16
to django...@googlegroups.com
When you say sorl 6.1.0 do you Solr? Sorl is an image thumbnail package.

When you say 2.5.0 do you mean Django Haystack 2.5.0? I don’t think 2.5.0 brought support for Solr 5, let alone Solr 6. Where did you read that? There are open issues on Django Haystack for Solr 5/6 support.

Elasticsearch support for Django Oscar is not complete, so as I mentioned the only way to get a search backend working for Django Oscar without having to write your own search backend is to use Solr 4.x

The Oscar documentation for using Solr 4.x and Django Haystack with Oscar did work for me.


--
https://github.com/tangentlabs/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
---
You received this message because you are subscribed to a topic in the Google Groups "django-oscar" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-oscar/vXaAlei6A9U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-oscar...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.
To view this discussion on the web, visit https://groups.google.com/d/msgid/django-oscar/bfdd69a0-d11b-4d82-8cff-b8a3c2ce9e0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

YusufSalahAdDin

unread,
Aug 15, 2016, 4:32:59 AM8/15/16
to django-oscar
Yes, i'm sorry, i'm talking to Solr. And yes, i'm talking about django-haystack 2.5.0. I had saw that these version have more wokd about Solr than ElasticSearch.

For now the documentation hasn't explain me how setup Solr, if you see the issue, in the current Oscar version the deploy folder has disappear from sandbox folder, begin for this is already a big problem.

PANKAJ GOYAL

unread,
Aug 15, 2016, 6:06:57 AM8/15/16
to django-oscar

So basically what I can conclude is -

ElasticSearch 2.3 is not supported in Django Haystack 2.5.0. ElasticSearch 2.x has removed facets.
Now I am getting switched to Apache Solr. So, what do I need to do?

Ubuntu 14.04 LTS
Python-2.7
Django-1.8 
Django-Oscar-1.1
Django-Haystack-2.5.0
Apache Solr - Which version to use - 4.10 or 5.0 or 6.1? Django haystack documentation shows configuration of Solr 4.10. But they say it supports Solr 3.5+.

I tried using Solr 6.1 and indexing done. But when I am searching, it shows me 400 Error [Undefined field: 'price_exact'].
This 'exact' field is I think created by django haystack because oscar creates only price field.

Arthur Case

unread,
Aug 15, 2016, 6:29:32 AM8/15/16
to django...@googlegroups.com
Solr version 4 is the only search engine I have had success with Oscar, out of the box so to speak. I’m running Solr 4.10.4

Oscar and Haystack could probably do with better documentation that stateß exactly which versions of search engines they support. There is an open pull request for Haystack to support Solr 5.



YusufSalahAdDin

unread,
Aug 16, 2016, 2:11:10 AM8/16/16
to django-oscar
Had you tried with the Solr 6.1.0 ?

Arthur Case

unread,
Aug 16, 2016, 2:27:44 AM8/16/16
to django...@googlegroups.com
As I wrote below, Solr 4.10 is the only version that I have used. Solr 5 or above, including Solr 6.1.0, does not work properly with Haystack or Oscar. There may be some customisations you can make to Haystack and Oscar to work around any issues. I have no experience of doing this however.

PANKAJ GOYAL

unread,
Aug 16, 2016, 2:56:59 AM8/16/16
to django-oscar

Yes Arthur is right. I myself tried Solr 6.1 and it didn't work out of the box. Now I am using Solr 4.10.4 and it is working like a charm. Thanks Arthur !!

YusufSalahAdDin

unread,
Aug 17, 2016, 1:58:12 AM8/17/16
to django-oscar
How did you try integrate with Solr 6.1 and which problems had you?

Whichs steps do you use for integrate with Solr 4.10.4?

PANKAJ GOYAL

unread,
Aug 17, 2016, 2:15:59 AM8/17/16
to django-oscar
I downloaded apache solr 6.1 tar ball.
I unzipped it.
I went to bin folder and fired the command - ./solr start -V
I created a core using the command - ./solr create -c corename -p 8983
I put the schema.xml file in conf directory.
I restarted the solr

In Django settings.py file - I configured the uri - http://localhost:8983/solr/corename


After doing all, i did python manage.py rebuild_index..

Indexing was successful.

The 400 error came while searching.. undefined field price_exact..

YusufSalahAdDin

unread,
Aug 19, 2016, 2:41:19 AM8/19/16
to django-oscar
Why you put this url http://localhost:8983/solr/corename?

I don't understand very good, why do you user this command ./solr create -c corename -p 8983?

YusufSalahAdDin

unread,
Aug 24, 2016, 12:29:47 AM8/24/16
to django-oscar
Can you explain me why do you user this command ./solr create -c corename -p 8983?

PANKAJ GOYAL

unread,
Aug 25, 2016, 2:40:27 AM8/25/16
to django-oscar

In Apache Solr 4.10.4, there is a default core named 'collection1'. So haystack connects to it.
But in Apache Solr 6.1, a core is to be created (check the user guide) and bind it to a port. And also tell haystack (in the solr uri itself) to connect to it.

PANKAJ GOYAL

unread,
Aug 25, 2016, 2:45:56 AM8/25/16
to django-oscar

Currently, I am using Apache Solr 4.10.4 and Django Haystack 2.5.0.
It was running fine, but suddenly all the documents got deleted from solr collection1.
And when I am running "python manage.py rebuild_schema", documents are not being added again.

This seems mysterious to me. Is it a bug in django oscar or django haystack or apache solr or what?

Arthur Case

unread,
Aug 25, 2016, 3:08:33 AM8/25/16
to django...@googlegroups.com
I havent had any problems like that with Solr 4.10.4 and Haystack 2.4.1 I’m using a version of Oscar. that requires django-haystack>=2.3.1,<2.5.0 in setup.py 

rebuild_schema does not add documents to an index though, use rebuild_index for that.


-- 
https://github.com/tangentlabs/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
--- 
You received this message because you are subscribed to a topic in the Google Groups "django-oscar" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-oscar/vXaAlei6A9U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-oscar...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.

PANKAJ GOYAL

unread,
Aug 25, 2016, 3:13:17 AM8/25/16
to django-oscar
It was a typo. I am using rebuild_index only

PANKAJ GOYAL

unread,
Aug 25, 2016, 3:14:05 AM8/25/16
to django-oscar
"I’m using a version of Oscar. that requires django-haystack>=2.3.1,<2.5.0 in setup.py" - Which version of oscar are you using? 

Arthur Case

unread,
Aug 25, 2016, 3:22:17 AM8/25/16
to django...@googlegroups.com
It was based on the master branch from a while ago, maybe 8 months old. I don’t think anything has changed in Oscar code for handling searches and search engines much since then though, the biggest related change I think was to require haystack 2.5.0 for Django 1.9 compatibility. I think your issue is more likely to be from haystack 2.5.0 rather than Oscar.

Reply all
Reply to author
Forward
0 new messages