mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-26 07:43:44 +00:00
Implemented __in lookup in ElasticSearch backend
Also added an error message if a user attempts to use a subquery with the __in lookup.
This commit is contained in:
parent
e35e20dd10
commit
b78b648682
1 changed files with 11 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import absolute_import
|
|||
import json
|
||||
|
||||
from django.db import models
|
||||
from django.db.models.sql.where import SubqueryConstraint
|
||||
|
||||
from elasticsearch import Elasticsearch, NotFoundError, RequestError
|
||||
from elasticsearch.helpers import bulk
|
||||
|
|
@ -201,7 +202,16 @@ class ElasticSearchQuery(object):
|
|||
}
|
||||
}
|
||||
|
||||
raise FilterError('Could not apply filter on ElasticSearch results "' + field_name + '__' + lookup + ' = ' + unicode(value) + '". Lookup "' + lookup + '"" not recognosed.')
|
||||
if lookup == 'in':
|
||||
return {
|
||||
'terms': {
|
||||
field_index_name: value,
|
||||
}
|
||||
}
|
||||
|
||||
raise FilterError('Could not apply filter on ElasticSearch results: "' + field_name + '__' + lookup + ' = ' + unicode(value) + '". Lookup "' + lookup + '"" not recognosed.')
|
||||
elif isinstance(where_node, SubqueryConstraint):
|
||||
raise FilterError('Could not apply filter on ElasticSearch results: Subqueries are not allowed.')
|
||||
|
||||
# Get child filters
|
||||
connector = where_node.connector
|
||||
|
|
|
|||
Loading…
Reference in a new issue