Skip to content

Commit

Permalink
Merge pull request #728 from WildMeOrg/es-sort-ordering-with-empty
Browse files Browse the repository at this point in the history
Fix Sort Ordering with Empty Data
  • Loading branch information
bluemellophone authored Jun 24, 2022
2 parents 5420a99 + 2cf611b commit 8dbe188
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/extensions/elasticsearch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import logging
import pprint
import sys
import time
import types
import uuid
Expand Down Expand Up @@ -36,6 +37,8 @@

ELASTICSEARCH_SORTING_PREFIX = 'elasticsearch.'

MAX_UNICODE_CODE_POINT_CHAR = chr(int(hex(sys.maxunicode), 16))

log = logging.getLogger('elasticsearch') # pylint: disable=invalid-name

# Global object session
Expand Down
4 changes: 3 additions & 1 deletion app/modules/individuals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ def get_first_name(self):
return first_name

def get_first_name_keyword(self):
from app.extensions.elasticsearch import MAX_UNICODE_CODE_POINT_CHAR

first_name = self.get_first_name()
if first_name is None:
first_name = ''
first_name = MAX_UNICODE_CODE_POINT_CHAR
first_name_keyword = first_name.strip().lower()
return first_name_keyword

Expand Down
4 changes: 3 additions & 1 deletion app/modules/sightings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,11 @@ def get_location_id_value(self):
return location_id_value

def get_location_id_keyword(self):
from app.extensions.elasticsearch import MAX_UNICODE_CODE_POINT_CHAR

location_id_value = self.get_location_id_value()
if location_id_value is None:
location_id_value = ''
location_id_value = MAX_UNICODE_CODE_POINT_CHAR
location_id_keyword = location_id_value.strip().lower()
return location_id_keyword

Expand Down

0 comments on commit 8dbe188

Please sign in to comment.