1
- function ( doc ) {
2
- const skip = [ '_id' , '_rev' , 'type' , 'refid' , 'geolocation' ] ;
1
+ function ( doc ) {
2
+ const skip = [ '_id' , '_rev' , 'type' , 'refid' , 'geolocation' ] ;
3
3
let toIndex = '' ;
4
4
5
- const types = [ 'district_hospital' , 'health_center' , 'clinic' , 'person' ] ;
5
+ const types = [ 'district_hospital' , 'health_center' , 'clinic' , 'person' ] ;
6
6
let idx ;
7
7
if ( doc . type === 'contact' ) {
8
8
idx = types . indexOf ( doc . contact_type ) ;
@@ -15,7 +15,7 @@ function(doc) {
15
15
16
16
const isContactDoc = idx !== - 1 ;
17
17
if ( isContactDoc ) {
18
- Object . keys ( doc ) . forEach ( function ( key ) {
18
+ Object . keys ( doc ) . forEach ( function ( key ) {
19
19
const value = doc [ key ] ;
20
20
if ( ! key || ! value ) {
21
21
return ;
@@ -28,14 +28,16 @@ function(doc) {
28
28
29
29
if ( typeof value === 'string' ) {
30
30
toIndex += ' ' + value ;
31
+ // index('text', key, value, { store: true });
31
32
}
32
33
33
- /* if (typeof value === 'number') {
34
- index('double', key, value, { store: true });
35
- }*/
34
+ if ( typeof value === 'number' ) {
35
+ // index('double', key, value, { store: true });
36
+ }
36
37
37
- /*if (typeof value === 'string') {
38
- index('text', key, value, { store: true });
38
+ /*const fieldNameRegex = /^\$?[a-zA-Z][a-zA-Z0-9_]*$/g
39
+ if (fieldNameRegex.test(key)) {
40
+ console.log(`key "${key}" doesn't pass regex`);
39
41
}*/
40
42
} ) ;
41
43
0 commit comments