diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 4eba8541..4a0171ea 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -78,4 +78,4 @@ jobs: FOLDER: build/docs/manual DOC_FOLDER: gh-pages COMMIT_EMAIL: behlp@objectcomputing.com - COMMIT_NAME: Puneet Behl \ No newline at end of file + COMMIT_NAME: Puneet Behl diff --git a/build.gradle b/build.gradle index 0ed1b9b2..6b23e4a3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ buildscript { repositories { + mavenLocal () maven { url "https://repo.grails.org/grails/core" } } dependencies { @@ -73,6 +74,7 @@ dependencies { compile "org.elasticsearch:elasticsearch:${elasticsearchVersion}" compile group: 'org.elasticsearch.client', name: 'elasticsearch-rest-client', version: elasticsearchVersion compile group: 'org.elasticsearch.client', name: 'elasticsearch-rest-high-level-client', version: elasticsearchVersion + compile "org.mongodb:mongodb-driver:3.9.1" compile group: 'org.locationtech.spatial4j', name: 'spatial4j', version: '0.8' console "org.grails:grails-console" @@ -83,6 +85,7 @@ dependencies { testRuntime 'org.apache.tomcat:tomcat-jdbc' testCompile "org.grails:grails-gorm-testing-support" +// testCompile "org.grails:grails-plugin-testing" testCompile "org.grails:grails-web-testing-support" testCompile 'com.vividsolutions:jts:1.13' diff --git a/gradle.properties b/gradle.properties index 1e371b2c..e184c550 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ projectVersion=3.0.2-SNAPSHOT grailsVersion=4.1.0 grailsGradlePluginVersion=4.1.0 gormHibernateVersion=7.0.5 -elasticsearchVersion=7.8.0 +elasticsearchVersion=7.8.1 org.gradle.caching=true org.gradle.daemon=true diff --git a/gradle/publish.gradle b/gradle/publish.gradle index 3ae6b9ba..a33d3408 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -18,4 +18,4 @@ githubPages { } } -task publishDocs(dependsOn: [docs, publishGhPages]) \ No newline at end of file +task publishDocs(dependsOn: [docs, publishGhPages]) diff --git a/grails-app/conf/application.yml b/grails-app/conf/application.yml index 3a273239..8c8472f8 100644 --- a/grails-app/conf/application.yml +++ b/grails-app/conf/application.yml @@ -32,6 +32,9 @@ spring: - grails-app/views/** - grails-app/i18n/** - grails-app/conf/** + autoconfigure: + exclude: + - org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration management: endpoints: enabled-by-default: false diff --git a/grails-app/services/grails/plugins/elasticsearch/ElasticSearchService.groovy b/grails-app/services/grails/plugins/elasticsearch/ElasticSearchService.groovy index 77f2592e..aaddd7ef 100755 --- a/grails-app/services/grails/plugins/elasticsearch/ElasticSearchService.groovy +++ b/grails-app/services/grails/plugins/elasticsearch/ElasticSearchService.groovy @@ -22,6 +22,7 @@ import grails.plugins.elasticsearch.index.IndexRequestQueue import grails.plugins.elasticsearch.mapping.SearchableClassMapping import grails.plugins.elasticsearch.util.GXContentBuilder import groovy.util.logging.Slf4j +import org.bson.types.MinKey import org.elasticsearch.action.search.SearchRequest import org.elasticsearch.action.search.SearchResponse import org.elasticsearch.client.RequestOptions @@ -58,6 +59,7 @@ class ElasticSearchService implements GrailsApplicationAware { private static final int INDEX_REQUEST = 0 private static final int DELETE_REQUEST = 1 + static final String MONGO_DATABASE = "mongoDatastore" GrailsApplication grailsApplication ElasticSearchHelper elasticSearchHelper @@ -352,13 +354,24 @@ class ElasticSearchService implements GrailsApplicationAware { } }*/ long offset = 0L + def id = new MinKey() (1..rounds).each { round -> try { log.debug("Bulk index iteration $round: fetching $max results starting from ${offset}") persistenceInterceptor.init() persistenceInterceptor.setReadOnly() - List> results = domainClass.listOrderById([offset: offset, max: max, readOnly: true, sort: 'id', order: "asc"]) + List> results + switch (grailsApplication.config.elasticsearch.datastoreImpl) { + case MONGO_DATABASE: + results = domainClass.createCriteria().list([offset: 0, max: max, readOnly: true, sort: 'id', order: "asc"]) { + gt 'id', id + } + break + default: + results = domainClass.listOrderById([offset: offset, max: max, readOnly: true, sort: 'id', order: "asc"]) + break + } // set lastId for next run offset = round * max @@ -372,6 +385,7 @@ class ElasticSearchService implements GrailsApplicationAware { indexRequestQueue.addDeleteRequest(entry) log.debug("Adding the document ${entry.id} to the delete request queue") } + id = entry.id } indexRequestQueue.executeRequests() diff --git a/src/main/groovy/grails/plugins/elasticsearch/mapping/SearchableClassPropertyMapping.groovy b/src/main/groovy/grails/plugins/elasticsearch/mapping/SearchableClassPropertyMapping.groovy index 5ec06d0d..4027c5ec 100644 --- a/src/main/groovy/grails/plugins/elasticsearch/mapping/SearchableClassPropertyMapping.groovy +++ b/src/main/groovy/grails/plugins/elasticsearch/mapping/SearchableClassPropertyMapping.groovy @@ -207,8 +207,7 @@ class SearchableClassPropertyMapping { * @return true if field is analyzed. NOTE it doesn't have to be stored. */ boolean isAnalyzed() { - String index = (String) mappingAttributes.index - (index == null || index) + mappingAttributes.get('index') != null ? mappingAttributes.get('index') == 'false' : true } /**