SearchQueryCompiler → BaseSearchQueryCompiler.

This commit is contained in:
Bertrand Bordage 2017-11-23 17:05:54 +01:00
parent 019f59f486
commit 71a7ca5808
5 changed files with 10 additions and 7 deletions

View file

@ -10,7 +10,7 @@ from django.db.models.functions import Cast
from django.utils.encoding import force_text
from wagtail.wagtailsearch.backends.base import (
BaseSearchBackend, SearchQueryCompiler, BaseSearchResults)
BaseSearchBackend, BaseSearchQueryCompiler, BaseSearchResults)
from wagtail.wagtailsearch.index import RelatedFields, SearchField
from wagtail.wagtailsearch.query import MatchAll, PlainText
@ -167,7 +167,7 @@ class Index(object):
return self.name
class PostgresSearchQueryCompiler(SearchQueryCompiler):
class PostgresSearchQueryCompiler(BaseSearchQueryCompiler):
DEFAULT_OPERATOR = 'and'
def __init__(self, *args, **kwargs):

View file

@ -19,7 +19,7 @@ class FieldError(Exception):
pass
class SearchQueryCompiler(object):
class BaseSearchQueryCompiler(object):
DEFAULT_OPERATOR = 'or'
def __init__(self, queryset, query, fields=None, operator=None, order_by_relevance=True):

View file

@ -4,11 +4,11 @@ from django.db import models
from django.db.models.expressions import Value
from wagtail.wagtailsearch.backends.base import (
BaseSearchBackend, SearchQueryCompiler, BaseSearchResults)
BaseSearchBackend, BaseSearchQueryCompiler, BaseSearchResults)
from wagtail.wagtailsearch.query import MatchAll, PlainText
class DatabaseSearchQueryCompiler(SearchQueryCompiler):
class DatabaseSearchQueryCompiler(BaseSearchQueryCompiler):
DEFAULT_OPERATOR = 'and'
def _process_lookup(self, field, lookup, value):

View file

@ -13,7 +13,7 @@ from elasticsearch.helpers import bulk
from wagtail.utils.utils import deep_update
from wagtail.wagtailsearch.backends.base import (
BaseSearchBackend, SearchQueryCompiler, BaseSearchResults)
BaseSearchBackend, BaseSearchQueryCompiler, BaseSearchResults)
from wagtail.wagtailsearch.index import (
FilterField, Indexed, RelatedFields, SearchField, class_is_indexed)
from wagtail.wagtailsearch.query import MatchAll, PlainText
@ -261,7 +261,7 @@ class Elasticsearch2Mapping(object):
return '<ElasticsearchMapping: %s>' % (self.model.__name__, )
class Elasticsearch2SearchQueryCompiler(SearchQueryCompiler):
class Elasticsearch2SearchQueryCompiler(BaseSearchQueryCompiler):
mapping_class = Elasticsearch2Mapping
DEFAULT_OPERATOR = 'or'

View file

@ -1,3 +1,6 @@
from __future__ import absolute_import, unicode_literals
class SearchQuery:
def __and__(self, other):
return And([self, other])