-
Notifications
You must be signed in to change notification settings - Fork 13
/
hostname.ts
47 lines (44 loc) · 1.42 KB
/
hostname.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { xLuceneFieldType, ESFieldType, xLuceneTypeConfig } from '@terascope/types';
import BaseType from '../base-type';
import { GraphQLType, TypeESMapping } from '../../interfaces';
export default class Hostname extends BaseType {
toESMapping(): TypeESMapping {
this._validateESMapping();
return {
mapping: {
[this.field]: {
type: 'text' as ESFieldType,
analyzer: 'lowercase_keyword_analyzer',
fields: {
tokens: {
type: 'text' as ESFieldType,
analyzer: 'hostname_analyzer',
},
},
},
},
analyzer: {
hostname_analyzer: {
type: 'custom',
tokenizer: 'hostname_tokenizer'
},
lowercase_keyword_analyzer: {
tokenizer: 'keyword',
filter: 'lowercase',
}
},
tokenizer: {
hostname_tokenizer: {
type: 'pattern',
pattern: '\\.'
}
},
};
}
toGraphQL(): GraphQLType {
return this._formatGql('String');
}
toXlucene(): xLuceneTypeConfig {
return { [this.field]: xLuceneFieldType.String };
}
}