Commit 58ce555f by Clinton Blackburn

Updated id and name analyzers

Using a lowercase keyword analyzer to better support wildcard queries.
parent 8a698034
......@@ -239,7 +239,7 @@ class CourseViewSetTests(ElasticsearchTestMixin, SerializationMixin, APITestCase
"must": [
{
"term": {
"course.name.lowercase_sort": name
"course.name": name
}
}
]
......
......@@ -2,7 +2,7 @@ COURSES_INDEX_CONFIG = {
'settings': {
'analysis': {
'analyzer': {
'case_insensitive_sort': {
'lowercase_keyword': {
'tokenizer': 'keyword',
'filter': ['lowercase']
}
......@@ -14,23 +14,11 @@ COURSES_INDEX_CONFIG = {
'properties': {
'id': {
'type': 'string',
'analyzer': 'english',
'fields': {
'lowercase_sort': {
'type': 'string',
'analyzer': 'case_insensitive_sort'
}
}
'analyzer': 'lowercase_keyword'
},
'name': {
'type': 'string',
'analyzer': 'english',
'fields': {
'lowercase_sort': {
'type': 'string',
'analyzer': 'case_insensitive_sort'
}
}
'analyzer': 'lowercase_keyword'
}
}
}
......
......@@ -102,7 +102,7 @@ class Course(object):
"""
query.setdefault('from', offset)
query.setdefault('size', limit)
query.setdefault('sort', {'id.lowercase_sort': 'asc'})
query.setdefault('sort', {'id': 'asc'})
logger.debug('Querying [%s]: %s', cls._index, query)
response = cls._es_client().search(index=cls._index, doc_type=cls.doc_type, body=query)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment