fix(_common.analysis): make PathHierarchyTokenizer fields optional - #1195
fix(_common.analysis): make PathHierarchyTokenizer fields optional#1195gingeekrishna wants to merge 2 commits into
Conversation
buffer_size, delimiter, reverse, and skip are optional in the OpenSearch API with documented defaults (buffer_size=1024, delimiter=/, reverse=false, skip=0). Marking them required caused MissingRequiredPropertyException when retrieving any index whose PathHierarchyTokenizer was configured with defaults (omitting those parameters). Only type is actually required. Remove the four optional fields from the required list; they remain defined as properties so they are still serialized/deserialized when present. Reported via opensearch-project/opensearch-java#1797 and fixed in opensearch-project/opensearch-java#2038. Signed-off-by: Radha Krishnan P <gingeekrishna@gmail.com>
| skip: | ||
| $ref: '_common.yaml#/components/schemas/StringifiedInteger' | ||
| required: | ||
| - buffer_size |
There was a problem hiding this comment.
this fixes path_hierarchy but AnalysisTokenizerPathHierarchyReverse has the exact same problem, it also marks buffer_size, delimiter, reverse, and skip as required. both types use the same factory class with the same defaults.
Can you fix that one too in this? otherwise half the bug is still there.
There was a problem hiding this comment.
Thanks for the review! I searched the repo for AnalysisTokenizerPathHierarchyReverse (and for any other schema with the same buffer_size/delimiter/reverse/skip shape) and couldn't find a second definition anywhere - PathHierarchyTokenizer in _common.analysis.yaml is the only one, and this PR already drops all four from its required list.
I also checked the OpenSearch server source (CommonAnalysisModulePlugin.java): it registers path_hierarchy and the deprecated camelCase alias PathHierarchy, both backed by the same PathHierarchyTokenizerFactory. reverse is just a boolean setting on that one factory, there's no separate reverse-specific tokenizer type server-side.
Could you point me to the exact file/line (or a link) for AnalysisTokenizerPathHierarchyReverse? Want to make sure I fix the right thing rather than guessing.
Description
Remove
buffer_size,delimiter,reverse, andskipfrom therequiredlist in thePathHierarchyTokenizerschema inspec/schemas/_common.analysis.yaml.All four fields are optional in the OpenSearch API with documented defaults (
buffer_size=1024,delimiter=/,reverse=false,skip=0). Marking them required causedMissingRequiredPropertyExceptionwhen retrieving any index whosePathHierarchyTokenizerwas configured with defaults, since OpenSearch omits default values from the response.Only
typeis actually required. The four fields remain defined as properties and continue to be serialized/deserialized when present.Related Issues
Reported via opensearch-java#1797 and the corresponding fix opensearch-java#2038, where reviewer @reta requested this upstream spec change.
Signed-off-by: Radha Krishnan P gingeekrishna@gmail.com