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 ...@@ -239,7 +239,7 @@ class CourseViewSetTests(ElasticsearchTestMixin, SerializationMixin, APITestCase
"must": [ "must": [
{ {
"term": { "term": {
"course.name.lowercase_sort": name "course.name": name
} }
} }
] ]
......
...@@ -2,7 +2,7 @@ COURSES_INDEX_CONFIG = { ...@@ -2,7 +2,7 @@ COURSES_INDEX_CONFIG = {
'settings': { 'settings': {
'analysis': { 'analysis': {
'analyzer': { 'analyzer': {
'case_insensitive_sort': { 'lowercase_keyword': {
'tokenizer': 'keyword', 'tokenizer': 'keyword',
'filter': ['lowercase'] 'filter': ['lowercase']
} }
...@@ -14,23 +14,11 @@ COURSES_INDEX_CONFIG = { ...@@ -14,23 +14,11 @@ COURSES_INDEX_CONFIG = {
'properties': { 'properties': {
'id': { 'id': {
'type': 'string', 'type': 'string',
'analyzer': 'english', 'analyzer': 'lowercase_keyword'
'fields': {
'lowercase_sort': {
'type': 'string',
'analyzer': 'case_insensitive_sort'
}
}
}, },
'name': { 'name': {
'type': 'string', 'type': 'string',
'analyzer': 'english', 'analyzer': 'lowercase_keyword'
'fields': {
'lowercase_sort': {
'type': 'string',
'analyzer': 'case_insensitive_sort'
}
}
} }
} }
} }
......
...@@ -102,7 +102,7 @@ class Course(object): ...@@ -102,7 +102,7 @@ class Course(object):
""" """
query.setdefault('from', offset) query.setdefault('from', offset)
query.setdefault('size', limit) query.setdefault('size', limit)
query.setdefault('sort', {'id.lowercase_sort': 'asc'}) query.setdefault('sort', {'id': 'asc'})
logger.debug('Querying [%s]: %s', cls._index, query) logger.debug('Querying [%s]: %s', cls._index, query)
response = cls._es_client().search(index=cls._index, doc_type=cls.doc_type, body=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