-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
onboard normalization processor (#311)
Signed-off-by: Tyler Ohlsen <[email protected]> (cherry picked from commit e913e41)
- Loading branch information
1 parent
c13ecb6
commit e40f057
Showing
8 changed files
with
199 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
public/configs/search_response_processors/normalization_processor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { PROCESSOR_TYPE } from '../../../common'; | ||
import { Processor } from '../processor'; | ||
|
||
/** | ||
* The normalization processor config. Used in search flows. | ||
*/ | ||
export class NormalizationProcessor extends Processor { | ||
constructor() { | ||
super(); | ||
this.type = PROCESSOR_TYPE.NORMALIZATION; | ||
this.name = 'Normalization Processor'; | ||
this.fields = []; | ||
this.optionalFields = [ | ||
{ | ||
id: 'weights', | ||
type: 'string', | ||
}, | ||
{ | ||
id: 'normalization_technique', | ||
type: 'select', | ||
selectOptions: ['min_max', 'l2'], | ||
}, | ||
{ | ||
id: 'combination_technique', | ||
type: 'select', | ||
selectOptions: ['arithmetic_mean', 'geometric_mean', 'harmonic_mean'], | ||
}, | ||
{ | ||
id: 'description', | ||
type: 'string', | ||
}, | ||
{ | ||
id: 'tag', | ||
type: 'string', | ||
}, | ||
]; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...pages/workflow_detail/workflow_inputs/processor_inputs/normalization_processor_inputs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiAccordion, EuiFlexItem, EuiSpacer } from '@elastic/eui'; | ||
import { | ||
IProcessorConfig, | ||
PROCESSOR_CONTEXT, | ||
WorkflowConfig, | ||
NORMALIZATION_PROCESSOR_LINK, | ||
} from '../../../../../common'; | ||
import { TextField } from '../input_fields'; | ||
import { ConfigFieldList } from '../config_field_list'; | ||
|
||
interface NormalizationProcessorInputsProps { | ||
uiConfig: WorkflowConfig; | ||
config: IProcessorConfig; | ||
baseConfigPath: string; // the base path of the nested config, if applicable. e.g., 'ingest.enrich' | ||
context: PROCESSOR_CONTEXT; | ||
} | ||
|
||
/** | ||
* Specialized component to render the normalization processor. Adds some helper text around weights field. | ||
* In the future, may have a more customizable / guided way for specifying the array of weights. | ||
* For example, could have some visual way of linking it to the underlying sub-queries in the query field, | ||
* enforce its length = the number of queries, etc. | ||
*/ | ||
export function NormalizationProcessorInputs( | ||
props: NormalizationProcessorInputsProps | ||
) { | ||
// extracting field info from the config | ||
const optionalFields = props.config.optionalFields || []; | ||
const weightsFieldPath = `${props.baseConfigPath}.${props.config.id}.weights`; | ||
const optionalFieldsWithoutWeights = optionalFields.filter( | ||
(field) => field.id !== 'weights' | ||
); | ||
|
||
return ( | ||
// We only have optional fields for this processor, so everything is nested under the accordion | ||
<EuiAccordion | ||
id={`advancedSettings${props.config.id}`} | ||
buttonContent="Advanced settings" | ||
paddingSize="none" | ||
> | ||
<EuiSpacer size="s" /> | ||
<EuiFlexItem> | ||
<TextField | ||
label={'Weights'} | ||
helpText={`A comma-separated array of floating-point values specifying the weight for each query. For example: '0.8, 0.2'`} | ||
helpLink={NORMALIZATION_PROCESSOR_LINK} | ||
fieldPath={weightsFieldPath} | ||
showError={true} | ||
/> | ||
</EuiFlexItem> | ||
<EuiSpacer size="s" /> | ||
<ConfigFieldList | ||
configId={props.config.id} | ||
configFields={optionalFieldsWithoutWeights} | ||
baseConfigPath={props.baseConfigPath} | ||
/> | ||
</EuiAccordion> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters