Skip to content

Commit

Permalink
starting to refactor towards version 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Jan 15, 2020
1 parent 1718dde commit 55ae859
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 9 deletions.
4 changes: 1 addition & 3 deletions shop/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
See PEP 386 (http://www.python.org/dev/peps/pep-0386/)
Expand All @@ -17,6 +15,6 @@
11. git commit -m 'Start with <version>'
12. git push
"""
__version__ = '1.1.1'
__version__ = '1.2.dev'

default_app_config = 'shop.apps.ShopConfig'
3 changes: 0 additions & 3 deletions shop/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _

Expand Down
53 changes: 50 additions & 3 deletions shop/search/indexes.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.template.loader import select_template
from django.utils import translation
from django.utils.html import strip_spaces_between_tags
from django.utils.safestring import mark_safe
from haystack import indexes

from elasticsearch_dsl import analyzer
from django_elasticsearch_dsl import Document, Index, fields
from django_elasticsearch_dsl.fields import TextField
from django_elasticsearch_dsl.registries import registry

from shop.models.product import ProductModel
from myshop.models import Product, SmartCard


class ProductIndex(indexes.SearchIndex):
Expand Down Expand Up @@ -62,3 +66,46 @@ def index_queryset(self, using=None):
else:
self.language = settings.LANGUAGE_CODE
return self.get_model().objects.indexable()


html_strip = analyzer(
'html_strip',
tokenizer="standard",
filter=["standard", "lowercase", "stop", "snowball"],
char_filter=["html_strip"]
)


products = Index('products')
products.settings(
number_of_shards=1,
number_of_replicas=0
)

@registry.register_document
@products.document
class ProductDocument(Document):
# product_name = fields.TextField(
# analyzer=html_strip,
# fields={
# 'raw': fields.TextField(analyzer='keyword'),
# }
# )

# product_url = indexes.CharField(stored=True, indexed=False, model_attr='get_absolute_url')

# description = fields.TextField(
# analyzer=html_strip,
# fields={
# 'raw': fields.TextField(analyzer='keyword'),
# }
# )
# class Index:
# # Name of the Elasticsearch index
# name = 'product'
# # See Elasticsearch Indices API reference for available settings
# settings = {'number_of_shards': 1, 'number_of_replicas': 0}

class Django:
model = ProductModel
fields = ['product_name']

0 comments on commit 55ae859

Please sign in to comment.