import { CmsModelFieldToElasticsearchPlugin } from "~/types" ; export default ( ) : CmsModelFieldToElasticsearchPlugin => ( { type : "cms-model-field-to-elastic-search" , name : "cms-model-field-to-elastic-search-default" , fieldType : "*" , toIndex ( { field , getFieldTypePlugin , value } ) { const fieldTypePlugin = getFieldTypePlugin ( field . type ) ; if ( fieldTypePlugin . isSearchable === true ) { return { value } ; } return { rawValue : value } ; } , fromIndex ( { field , getFieldTypePlugin , value , rawValue } ) { const { isSearchable } = getFieldTypePlugin ( field . type ) ; return isSearchable === true ? value : rawValue ; } } ) ;