cancel
Showing results for 
Search instead for 
Did you mean: 

how to delete data from flexible search query in hac

Former Member
0 Kudos

how can i delete data from hac console?

Former Member
0 Kudos

You can't delete data using flexible search query

Former Member
0 Kudos

Any other way without physically deleting them from the database??

Former Member

Accepted Solutions (1)

Accepted Solutions (1)

andyfletcher
Active Contributor
0 Kudos

Use Groovy to loop over the result of your flexible search from the scripting languages console

 flexibleSearchService.search(/select {pk} from {product}/).result.each {
   modelService.remove(it)
 }

This would delete all products returned by the query (i.e. all of them!)

I'm using Groovy's "slashy string" so that you can easily use quotes in your query. It's also multiline by default so this still works for better readability of the query:

 flexibleSearchService.search(/
   select {pk}
   from {product}
   where {code} like 'ABC%'
 /).result.each {
   println it.code
 }

it is an implicit variable that means the current value of the iterator inside the closure. I.e. in this case the current product.

Don't forget to slide the ROLLBACK switch to COMMIT before executing. As pointed out on another post, Just be careful in production!

Answers (2)

Answers (2)

Former Member
0 Kudos

Yo can use ImpEx, like:

 REMOVE Product[batchmode=true];catalogVersion(catalog(id),version)[unique=true]
 ;productCatalog:Staged

But if you want to build complex query and remove it's results - my vote for Groovy

VinayKumarS
Active Contributor
0 Kudos

There is a SQL Query Tab next to Flexible Search Query. Usually we used to delete the data using that.

Please make sure you do a soft delete. Hard delete on production is not accepted. That might leads to an issue. Double check before performing this activity on prod.

Former Member
0 Kudos

As i know,it can use impex file included REMOVE mode to update data, So this way is soft delete or hard delete? Best Regards, Devin

VinayKumarS
Active Contributor
0 Kudos

its overwriting 🙂 not exactly removing