Skip to content

Commit

Permalink
ES sorting on users fields
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Oct 23, 2020
1 parent 2828633 commit ee22992
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/common/management/commands/import_lookup_values.py
Expand Up @@ -93,7 +93,7 @@ def create_concepts(source, file, user):
data['mnemonic'] = mnemonic
data['name'] = mnemonic
data['parent'] = source
Concept.persist_new(data, user, False)
Concept.persist_new(data, user)
if not created:
created = True
return created
7 changes: 4 additions & 3 deletions core/users/documents.py
Expand Up @@ -11,12 +11,13 @@ class Index:
settings = {'number_of_shards': 1, 'number_of_replicas': 0}

date_joined = fields.DateField(attr='created_at')
username = fields.KeywordField(attr='username', normalizer='lowercase')
location = fields.KeywordField(attr='location', normalizer='lowercase')
company = fields.KeywordField(attr='company', normalizer='lowercase')
name = fields.KeywordField(attr='name', normalizer='lowercase')

class Django:
model = UserProfile
fields = [
'username',
'company',
'location',
'is_active'
]
4 changes: 2 additions & 2 deletions core/users/views.py
Expand Up @@ -20,8 +20,8 @@ class UserBaseView(BaseAPIView):
es_fields = {
'username': {'sortable': True, 'filterable': True, 'exact': True},
'date_joined': {'sortable': True, 'default': 'asc', 'filterable': True},
'company': {'sortable': False, 'filterable': True, 'exact': True},
'location': {'sortable': False, 'filterable': True, 'exact': True},
'company': {'sortable': True, 'filterable': True, 'exact': True},
'location': {'sortable': True, 'filterable': True, 'exact': True},
}
document_model = UserProfileDocument
is_searchable = True
Expand Down

0 comments on commit ee22992

Please sign in to comment.