This repository was archived by the owner on May 28, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +18
-29
lines changed Expand file tree Collapse file tree 3 files changed +18
-29
lines changed Original file line number Diff line number Diff line change @@ -96,18 +96,16 @@ const es5RebuildCommand = (cmd) => { // TODO: add parallel processing
9696 } )
9797}
9898
99- const rebuildCommandFactory = ( cmd ) => {
100- if ( parseInt ( config . elasticsearch . apiVersion ) < 6 ) {
101- return es5RebuildCommand ( cmd )
102- } else {
103- return es7RebuildCommand ( cmd )
104- }
105- }
106-
10799program
108100 . command ( 'rebuild' )
109101 . option ( '-i|--indexName <indexName>' , 'name of the Elasticsearch index' , config . elasticsearch . indices [ 0 ] )
110- . action ( rebuildCommandFactory )
102+ . action ( ( cmd ) => {
103+ if ( parseInt ( config . elasticsearch . apiVersion ) < 6 ) {
104+ return es5RebuildCommand ( cmd )
105+ } else {
106+ return es7RebuildCommand ( cmd )
107+ }
108+ } )
111109
112110/**
113111 * CREATE INDEX
@@ -159,18 +157,16 @@ const es5NewCommand = (cmd) => { // TODO: add parallel processing
159157 } )
160158}
161159
162- const newCommandFactory = ( cmd ) => {
163- if ( parseInt ( config . elasticsearch . apiVersion ) < 6 ) {
164- return es5NewCommand ( cmd )
165- } else {
166- return es7NewCommand ( cmd )
167- }
168- }
169-
170160program
171161 . command ( 'new' )
172162 . option ( '-i|--indexName <indexName>' , 'name of the Elasticsearch index' , config . elasticsearch . indices [ 0 ] )
173- . action ( newCommandFactory )
163+ . action ( ( cmd ) => {
164+ if ( parseInt ( config . elasticsearch . apiVersion ) < 6 ) {
165+ return es5NewCommand ( cmd )
166+ } else {
167+ return es7NewCommand ( cmd )
168+ }
169+ } )
174170
175171/**
176172 * OTHERS COMMANDS
Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ function getMagentoDefaultConfig (storeCode) {
4141 REDIS_DB : config . redis . db ,
4242 REDIS_AUTH : config . redis . auth ,
4343 INDEX_NAME : config . elasticsearch . indices [ 0 ] ,
44- DATABASE_URL : `${ config . elasticsearch . protocol } ://${ config . elasticsearch . host } :${ config . elasticsearch . port } `
44+ DATABASE_URL : `${ config . elasticsearch . protocol } ://${ config . elasticsearch . host } :${ config . elasticsearch . port } ` ,
45+ ELASTICSEARCH_API_VERSION : config . elasticsearch . apiVersion
4546 }
4647}
4748
Original file line number Diff line number Diff line change @@ -202,19 +202,11 @@ function loadSchema (entityType, apiVersion = '7.1') {
202202 return null
203203 }
204204 let schemaContent = jsonFile . readFileSync ( rootSchemaPath )
205- let elasticSchema = parseInt ( apiVersion ) < 6 ? schemaContent : Object . assign ( { } , {
206- mappings : {
207- [ entityType ] : schemaContent
208- }
209- } ) ;
205+ let elasticSchema = parseInt ( apiVersion ) < 6 ? schemaContent : Object . assign ( { } , { mappings : schemaContent } ) ;
210206 const extensionsPath = path . join ( __dirname , '../../config/elastic.schema.' + entityType + '.extension.json' ) ;
211207 if ( fs . existsSync ( extensionsPath ) ) {
212208 schemaContent = jsonFile . readFileSync ( extensionsPath )
213- let elasticSchemaExtensions = parseInt ( apiVersion ) < 6 ? schemaContent : Object . assign ( { } , {
214- mappings : {
215- [ entityType ] : schemaContent
216- }
217- } ) ;
209+ let elasticSchemaExtensions = parseInt ( apiVersion ) < 6 ? schemaContent : Object . assign ( { } , { mappings : schemaContent } ) ;
218210 elasticSchema = _ . merge ( elasticSchema , elasticSchemaExtensions ) // user extensions
219211 }
220212 return elasticSchema
You can’t perform that action at this time.
0 commit comments