@@ -22,6 +22,137 @@ document_conversion.convert({
22
22
}
23
23
}
24
24
} , function ( err , response ) {
25
+ console . log ( "----------\n" ) ;
26
+ console . log ( "convert a single document\n" ) ;
27
+ console . log ( "----------\n" ) ;
28
+ if ( err ) {
29
+ console . error ( err ) ;
30
+ } else {
31
+ console . log ( JSON . stringify ( response , null , 2 ) ) ;
32
+ }
33
+ } ) ;
34
+
35
+ // dry run of indexing a single document
36
+ document_conversion . index ( {
37
+ file : fs . createReadStream ( __dirname + '/resources/sample-docx.docx' ) ,
38
+ config : {
39
+ retrieve_and_rank : {
40
+ dry_run : true
41
+ }
42
+ }
43
+ } , function ( err , response ) {
44
+ console . log ( "----------\n" ) ;
45
+ console . log ( "dry run of indexing a single document\n" ) ;
46
+ console . log ( "----------\n" ) ;
47
+ if ( err ) {
48
+ console . error ( err ) ;
49
+ } else {
50
+ console . log ( JSON . stringify ( response , null , 2 ) ) ;
51
+ }
52
+ } ) ;
53
+
54
+ // dry run of indexing only metadata
55
+ document_conversion . index ( {
56
+ metadata : {
57
+ metadata : [
58
+ { name : 'id' , value : '1' } ,
59
+ { name : 'SomeMetadataName' , value : 'SomeMetadataValue' }
60
+ ]
61
+ } ,
62
+ config : {
63
+ retrieve_and_rank : {
64
+ dry_run : true
65
+ }
66
+ }
67
+ } , function ( err , response ) {
68
+ console . log ( "----------\n" ) ;
69
+ console . log ( "dry run of indexing only metadata\n" ) ;
70
+ console . log ( "----------\n" ) ;
71
+ if ( err ) {
72
+ console . error ( err ) ;
73
+ } else {
74
+ console . log ( JSON . stringify ( response , null , 2 ) ) ;
75
+ }
76
+ } ) ;
77
+
78
+ // dry run of indexing a single document with metadata and additional configuration for convert_document and field mapping
79
+ document_conversion . index ( {
80
+ file : fs . createReadStream ( __dirname + '/resources/example.html' ) ,
81
+ metadata : {
82
+ metadata : [
83
+ { name : 'id' , value : '2' } ,
84
+ { name : 'Author' , value : 'IBM' } ,
85
+ { name : 'Date Created' , value : '2016-03-21' } ,
86
+ { name : 'Category' , value : 'Example' }
87
+ ]
88
+ } ,
89
+ config : {
90
+ convert_document : {
91
+ normalized_html : {
92
+ // Exclude all anchor tags "<a>"
93
+ exclude_tags_completely : [ 'a' ]
94
+ }
95
+ } ,
96
+ retrieve_and_rank : {
97
+ dry_run : true ,
98
+ fields : {
99
+ mappings : [
100
+ { from : 'Author' , to : 'Created By' } ,
101
+ { from : 'Date Created' , to : 'Created On' }
102
+ ] ,
103
+ include : [
104
+ 'Created By' ,
105
+ 'Created On'
106
+ ] ,
107
+ exclude : [
108
+ 'Category'
109
+ ]
110
+ }
111
+ }
112
+ }
113
+ } , function ( err , response ) {
114
+ console . log ( "----------\n" ) ;
115
+ console . log ( "dry run of indexing a single document with metadata and additional configuration for convert_document and field mappings\n" ) ;
116
+ console . log ( "----------\n" ) ;
117
+ if ( err ) {
118
+ console . error ( err ) ;
119
+ } else {
120
+ console . log ( JSON . stringify ( response , null , 2 ) ) ;
121
+ }
122
+ } ) ;
123
+
124
+ // indexing a single document with metadata and additional configuration for convert_document and field mappings
125
+ document_conversion . index ( {
126
+ file : fs . createReadStream ( __dirname + '/resources/example.html' ) ,
127
+ metadata : {
128
+ metadata : [
129
+ { name : 'id' , value : '3' } ,
130
+ { name : 'SomeMetadataName' , value : 'SomeMetadataValue' }
131
+ ]
132
+ } ,
133
+ config : {
134
+ convert_document : {
135
+ normalized_html : {
136
+ // Exclude all anchor tags "<a>"
137
+ exclude_tags_completely : [ 'a' ]
138
+ }
139
+ } ,
140
+ retrieve_and_rank : {
141
+ dry_run : false ,
142
+ service_instance_id : 'INSERT YOUR RETRIEVE AND RANK SERVICE INSTANCE ID HERE' ,
143
+ cluster_id : 'INSERT YOUR RETRIEVE AND RANK SERVICE SOLR CLUSTER ID HERE' ,
144
+ search_collection : 'INSERT YOUR RETRIEVE AND RANK SERVICE SOLR SEARCH COLLECTION NAME HERE' ,
145
+ fields : {
146
+ mappings : [
147
+ { from : 'SomeMetadataName' , to : 'Created By' }
148
+ ]
149
+ }
150
+ }
151
+ }
152
+ } , function ( err , response ) {
153
+ console . log ( "----------\n" ) ;
154
+ console . log ( "indexing a single document with metadata and additional configuration for convert_document and field mappings\n" ) ;
155
+ console . log ( "----------\n" ) ;
25
156
if ( err ) {
26
157
console . error ( err ) ;
27
158
} else {
0 commit comments