This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from eregs/475-pgsql
Add an initial Postgres backend for search
- Loading branch information
Showing
24 changed files
with
473 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
regcore\_pgsql\.management\.commands package | ||
============================================ | ||
|
||
Submodules | ||
---------- | ||
|
||
regcore\_pgsql\.management\.commands\.rebuild\_pgsql\_index module | ||
------------------------------------------------------------------ | ||
|
||
.. automodule:: regcore_pgsql.management.commands.rebuild_pgsql_index | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: regcore_pgsql.management.commands | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
regcore\_pgsql\.management package | ||
================================== | ||
|
||
Subpackages | ||
----------- | ||
|
||
.. toctree:: | ||
|
||
regcore_pgsql.management.commands | ||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: regcore_pgsql.management | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
regcore\_pgsql\.migrations package | ||
================================== | ||
|
||
Submodules | ||
---------- | ||
|
||
regcore\_pgsql\.migrations\.0001\_initial module | ||
------------------------------------------------ | ||
|
||
.. automodule:: regcore_pgsql.migrations.0001_initial | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
regcore\_pgsql\.migrations\.0002\_documentindex\_doc\_root module | ||
----------------------------------------------------------------- | ||
|
||
.. automodule:: regcore_pgsql.migrations.0002_documentindex_doc_root | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: regcore_pgsql.migrations | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
regcore\_pgsql package | ||
====================== | ||
|
||
Subpackages | ||
----------- | ||
|
||
.. toctree:: | ||
|
||
regcore_pgsql.management | ||
regcore_pgsql.migrations | ||
regcore_pgsql.tests | ||
|
||
Submodules | ||
---------- | ||
|
||
regcore\_pgsql\.models module | ||
----------------------------- | ||
|
||
.. automodule:: regcore_pgsql.models | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
regcore\_pgsql\.views module | ||
---------------------------- | ||
|
||
.. automodule:: regcore_pgsql.views | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: regcore_pgsql | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
regcore\_pgsql\.tests package | ||
============================= | ||
|
||
Submodules | ||
---------- | ||
|
||
regcore\_pgsql\.tests\.rebuild\_pgsql\_index\_tests module | ||
---------------------------------------------------------- | ||
|
||
.. automodule:: regcore_pgsql.tests.rebuild_pgsql_index_tests | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
regcore\_pgsql\.tests\.views\_tests module | ||
------------------------------------------ | ||
|
||
.. automodule:: regcore_pgsql.tests.views_tests | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: regcore_pgsql.tests | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
] | ||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.contenttypes', | ||
'mptt', | ||
'haystack', | ||
'regcore', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from regcore.settings.base import * # noqa | ||
|
||
INSTALLED_APPS.remove('haystack') | ||
INSTALLED_APPS.extend(['regcore_pgsql', 'django.contrib.postgres']) | ||
SEARCH_HANDLER = 'regcore_pgsql.views.search' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from model_mommy.recipe import Recipe | ||
|
||
from regcore.models import Document | ||
|
||
|
||
# Account for mptt-related edge case | ||
doc_recipe = Recipe(Document, lft=None, rght=None, tree_id=None, | ||
_fill_optional=['title']) |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import logging | ||
|
||
from django.core.management.base import BaseCommand | ||
from django.db import transaction | ||
|
||
from regcore.models import Document | ||
from regcore_pgsql.models import DocumentIndex | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def section_documents(): | ||
return Document.objects\ | ||
.filter(label_string__contains='-')\ | ||
.exclude(label_string__regex=r'.*-.*-.*') | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Rebuild document indexes for searching sections within Postgres" | ||
|
||
@transaction.atomic | ||
def handle(self, *args, **options): | ||
DocumentIndex.objects.all().delete() | ||
count = section_documents().count() | ||
for idx, document in enumerate(section_documents().iterator()): | ||
if idx % 100 == 0: | ||
logger.info('Inserted DocumentIndex %s / %s', idx, count) | ||
DocumentIndex.from_document(document).save() | ||
DocumentIndex.rebuild_search_vectors() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.3 on 2017-08-04 15:27 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('regcore_pgsql', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='documentindex', | ||
name='doc_root', | ||
field=models.SlugField(default='', max_length=200), | ||
preserve_default=False, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.