Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add Gin index for product full text search

Jakub Draganekdefb4d906b18
diff --git a/saleor/product/migrations/0038_auto_20171129_0616.py b/saleor/product/migrations/0038_auto_20171129_0616.py
new file mode 100644
index 0000000000..9b940fb761
--- /dev/null
+++ b/saleor/product/migrations/0038_auto_20171129_0616.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.5 on 2017-11-29 12:16
+from __future__ import unicode_literals
+
+from django.contrib.postgres.operations import BtreeGinExtension
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('product', '0037_auto_20171124_0847'),
+ ]
+
+ operations = [
+ BtreeGinExtension()
+ ]
diff --git a/saleor/product/models.py b/saleor/product/models.py
index dce0420cd8..1e5bf0ee91 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -5,6 +5,7 @@ from decimal import Decimal
from django.conf import settings
from django.contrib.postgres.fields import HStoreField
+from django.contrib.postgres.indexes import GinIndex
from django.core.validators import MinValueValidator, RegexValidator
from django.db import models
from django.db.models import F, Max, Q
@@ -140,6 +141,7 @@ class Product(models.Model, ItemRange):
class Meta:
app_label = 'product'
+ indexes = [GinIndex(fields=['name', 'description'])]
permissions = (
('view_product',
pgettext_lazy('Permission description', 'Can view products')),