-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(java) Use alias for name search sorting and fix missing mappings #8648
fix(java) Use alias for name search sorting and fix missing mappings #8648
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Want to throw an aliased field on test-models/src/main/pegasus/com/datahub/test/TestEntityInfo.pdl
and add a test to MappingsBuilderTest.java
? I have an example in my ngrams PR: https://github.com/datahub-project/datahub/pull/8611/files#diff-fc3cb0e02650522d68bf55a60f21a6d6942f0e87c0e61234a8c20c518f62a41a
private static Map<String, Object> getMappingsForFieldNameAliases(@Nonnull final SearchableFieldSpec searchableFieldSpec) { | ||
Map<String, Object> mappings = new HashMap<>(); | ||
List<String> fieldNameAliases = searchableFieldSpec.getSearchableAnnotation().getFieldNameAliases(); | ||
if (fieldNameAliases.size() > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we technically don't need this check as it will just not execute anything if we call forEach on an empty list but I leave it up to you if you want to remove it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup that makes sense!
a4cb81c
into
datahub-project:master
There were two problems with our search sorting and this solves both of them.
The simpler one: If an index didn't have a field that we were sorting by (such as
lastOperationTime
) ES would throw an error and not return any results from that index. Instead, we want to pretend like that field exists on the index but just not sort in it. This change is just addingunmappedType
inESUtils.java
in our search request.We want to sort by entity name but unfortunately
name
isn't the name of the field in all elastic indices. So now i'm introducing a new concept to ourSearchableAnnotation
calledfieldNameAliases
which is an array of possible aliases for a given field. This sets the alias on the mapping so we can sort by it. Thename
alias is going to be_entityName
to avoid any clashes with existing fields and now the frontend sorts on that.Checklist