fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix
[wolnelektury.git]
/
src
/
catalogue
/
models
/
snippet.py
diff --git
a/src/catalogue/models/snippet.py
b/src/catalogue/models/snippet.py
index
3c9384c
..
4c25b8c
100644
(file)
--- a/
src/catalogue/models/snippet.py
+++ b/
src/catalogue/models/snippet.py
@@
-1,23
+1,27
@@
from django.db import models
from django.db import models
+from django.contrib.postgres.indexes import GinIndex
from django.contrib.postgres.search import SearchVector, SearchVectorField
from django.contrib.postgres.search import SearchVector, SearchVectorField
-from search.utils import
build_search_v
ector
+from search.utils import
UnaccentSearchV
ector
class Snippet(models.Model):
book = models.ForeignKey('Book', models.CASCADE)
sec = models.IntegerField()
class Snippet(models.Model):
book = models.ForeignKey('Book', models.CASCADE)
sec = models.IntegerField()
- # header_type ?
- # header_span ?
text = models.TextField()
search_vector = SearchVectorField()
text = models.TextField()
search_vector = SearchVectorField()
+ class Meta:
+ indexes = [
+ GinIndex('search_vector', name='search_vector_idx'),
+ ]
+
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
if not self.search_vector:
self.update()
def update(self):
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
if not self.search_vector:
self.update()
def update(self):
- self.search_vector =
build_search_v
ector('text')
+ self.search_vector =
UnaccentSearchV
ector('text')
self.save()
@classmethod
self.save()
@classmethod