Skip to main content

Pure Postgresql search backend for Django Oscar

Project description

Maintainability Maintainability Test Coverage image image

Postgresql search handler for Django-Oscar

This creates a search handler without the need of any search backend. It is designed for the e-commerce framework Oscar.

It is implemented a little bit expensive but uses 4 annotated search vectors: * upc * title * meta_description * meta_title

This way the search can be manipulated through the meta fields. It is running productive in a heavily customized env for many months now. I think it should scale up to 5000 Products with 10 Attributes depending on how the products are loaded. We use it fully lazy with endless scrolling.

To-Do

  • Provide a generic way to use filter forms
  • Writing Tests

Features

  • Don't need to use some additional search backend like elastic
  • Creates filters (facets) for:
    • Data that is directly attached to the Product model
    • including foreign key choices
    • AttributeValues of the products
    • StockRecord entries

Installation

Basic

Install using pip:

pip install django-oscar-pg-search
# settings.py

# replace 'oscar.apps.search.apps.SearchConfig' by 'oscar_pg_search.apps.PgSearchConfig'
INSTALLED_APPS = [
	# 'oscar.apps.search.apps.SearchConfig',
    'oscar_pg_search.apps.PgSearchConfig',
]

OSCAR_PRODUCT_SEARCH_HANDLER = 'oscar_pg_search.postgres_search_handler.PostgresSearchHandler'

# To avoid exception, haystack is not used:
HAYSTACK_CONNECTIONS = {"default": {}}

Trigram search is our search algorithm. Enable it at your database by executing the following sql:

CREATE EXTENSION pg_trgm;

Optional Search box

To install the included Search box that passes the previous search term. (eg. in 'oscar/partials/search.html')

{% include 'oscar_pg_search/partials/search.html' %}

Optional Filter Forms

To use the included filter forms, include them in the template eg. in 'oscar/layout_2_col.html' after '{% block column_left_extra %}{% endblock %}'.

{% include 'oscar_pg_search/catalogue/partials/filter_forms.html' %}

and include the mixin into the catalogue views.

# apps/catalogue/views.py
from oscar.apps.catalogue import views
from oscar_pg_search.mixins import SearchViewMixin


class CatalogueView(SearchViewMixin, views.CatalogueView):
    pass


class ProductCategoryView(SearchViewMixin, views.ProductCategoryView):
    pass

Optional Use Chosen.js

To empower multiple choice fields with chosen load it eg. in 'oscar/base.html'.

# At the beginning:
{% load oscar_pg_search %}

# After jQuery is loaded:
{% oscar_pg_search_base %}

Settings

If you want to add some fields that are directly attached to the Product model:

# settings.py
OSCAR_ATTACHED_PRODUCT_FIELDS = ['is_public', 'deposit', 'volume', 'weight',]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-oscar-pg-search-0.9.8.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

django_oscar_pg_search-0.9.8-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file django-oscar-pg-search-0.9.8.tar.gz.

File metadata

File hashes

Hashes for django-oscar-pg-search-0.9.8.tar.gz
Algorithm Hash digest
SHA256 dd5dd8db00ff1dad043682bdb92c4248f9f65e1917d1ebdfc86fc569e43d6669
MD5 290b08b882f49c6c3d300d12bb36e808
BLAKE2b-256 12f6338cb7e9ee72481c3a2d51d54f53c731685dc9e4d85e91e29b7e74aaad01

See more details on using hashes here.

Provenance

File details

Details for the file django_oscar_pg_search-0.9.8-py3-none-any.whl.

File metadata

File hashes

Hashes for django_oscar_pg_search-0.9.8-py3-none-any.whl
Algorithm Hash digest
SHA256 81e17fdf971d213e7f8c0b85d623fded09ff9af0d95d3e6eab4f22afb58b011b
MD5 8296a914761eedc0267c4c4a6ba6f99a
BLAKE2b-256 69ba2b854727347d1d0891b6cdf46bcea49e66321fdcd71222a3360c6cb79d53

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page