Skip to content

Commit

Permalink
fixed deleting unreachable data
Browse files Browse the repository at this point in the history
  • Loading branch information
temi committed Aug 2, 2021
1 parent 6beae6a commit 1b618c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions grails-app/services/au/org/ala/profile/SearchService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -856,13 +856,13 @@ class SearchService extends BaseDataAccessService {

def jsonSlurper = new JsonSlurper()
def query = jsonSlurper.parseText('{"query": {"match_all": {}}}')
def resp = webService.post(elasticSearchUrl + "/_search", query, [:], ContentType.APPLICATION_JSON, false, false, [:])
def resp = webService.post(elasticSearchUrl + "/au.org.ala.profile/_search", query, [:], ContentType.APPLICATION_JSON, false, false, [:])

Integer total = resp?.resp?.hits?.total?: 0

if (total > 0) {
// must add q:scientificName:* for deletion to make sure that it is only data that is deleted and not the index itself, i.e. au.org.ala.profile_v0
webService.delete("${elasticSearchUrl}/${resp?.resp?.hits?.hits[0]._index}/profile/_query" , ['q':'scientificName:*'], ContentType.APPLICATION_JSON, false, false, [:])
webService.post("${elasticSearchUrl}/${resp?.resp?.hits?.hits[0]._index}/profile/_delete_by_query" , null, ['q':'scientificName:*'], ContentType.APPLICATION_JSON, false, false, [:])
}
["RecordsDeleted": total]
}
Expand Down

0 comments on commit 1b618c8

Please sign in to comment.