Hey all! Curious if there's a workaround for using...
# feature-requests
o
Hey all! Curious if there's a workaround for using the @Searchable annotation on a sub-PDL type that gets used for multiple fields in the top-level type in a has-a relationship. Since the searchable annotation requires the name to be input at the PDL level, model validation throws an error because having two indexed fields with the same name is not allowed. Example:
Copy code
Object {
field1: SubObject
field2: SubObject
}

SubObject {
@Searchable {
"fieldName": "field"
"fieldType": "TEXT_PARTIAL"
}
field: Field
}
e
Hey! Take a look at how we handle overrides of annotations here https://github.com/linkedin/datahub/blob/master/metadata-models/src/main/pegasus/com/linkedin/schema/SchemaField.pdl#L59 We have the annotation on TagAssociation which is used on the entity level but also field level
So we set an override from the field tags side saying
for the field that you can reach by following the path β€œ/tags/*/tag”, set this Searchable annotation
So in your above example, you can set an override on field2 as below
Copy code
@Searchable = {
  "/field": {
    "fieldName": "field2Field",
    "fieldType": "TEXT_PARTIAL"
  }
}
field2: SubObject
thankyou 1
note * above in the tag path denotes that it is an element of a list
o
Awesome! Thanks Dexter πŸ™‚
e
Let us know how it goes!! We would luv your feedback on how these annotations work!
o
It worked perfectly, added in the override and everything went through πŸ™‚ definitely like searchability being tied directly to the schema rather than having to maintain a separate search schema alongside the base schema. Makes changes a lot less error-prone.
e
Glad to hear!!!
o
I did have one gripe in the error message though, I added the full aspect named path to the error message in
SearchableFieldSpecExtractor
locally to be able to find where the issue was. I was making a lot of schema changes at once so maybe not the most common issue, but I think it's quite helpful for troubleshooting and made finding my issue much easier.
The current error message just gives the duplicate searchable field name without context of what file it's on.
Happy to push that out if it seems like a reasonable add
e
That was something on our mind for a long time! If you haev a quick solution in mind, feel free to make the changes!!!
That would be amazing
πŸ‘ 1