import { xLuceneFieldType , ESFieldType , xLuceneTypeConfig } from '@terascope/types' ; import BaseType from '../base-type' ; import { GraphQLType , TypeESMapping } from '../../interfaces' ; export default class NgramTokens extends BaseType { toESMapping ( _version ? ) { if ( this . config . indexed === false ) { throw new Error ( `${ this . constructor . name } is required to be indexed` ) ; } return { mapping : { [ this . field ] : { type : 'keyword' as ESFieldType , fields : { tokens : { type : 'text' as ESFieldType , analyzer : 'ngram_analyzer' , } , } , } , } , analyzer : { ngram_analyzer : { tokenizer : 'ngram_tokenizer' , } , } , tokenizer : { ngram_tokenizer : { type : 'ngram' , min_gram : 3 , max_gram : 3 , token_chars : [ 'digit' ] , } , } , } ; } toGraphQL ( ) { return this . _formatGql ( 'String' ) ; } toXlucene ( ) { return { [ this . field ] : xLuceneFieldType . String } ; } }