Developers
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
New Creator

Delete invalid asset from Index

Jump to solution

I see invalid data showing up in my search and on analysis I found the asset id showing up on search results does not exist anymore and neither could be found in deleted items.

The delete defined in SearchHelper.cs  SearchOperation() does not help me as it clears the index based on asset and my asset does not exist. (below code is used in crownpeak)

if (_asset.Raw["exclude_from_search"].ToString() == "true")
{
var search = new SearchHelper(_context, _asset, SearchG2JsonParams.OperationType.Delete);
search = AddJsonParams(search);
search.AddJsonParamsToContext();
}

 

To fix this I need a solution to:

1. How to completely delete or clean up the Index? (without referencing to any asset)

2. How to delete Index for specific asset ID which doesn't exist?

 

 

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Crownpeak Employee
Crownpeak Employee

Re: Delete invalid asset from Index

Jump to solution

For #1. Unfortunately, there isn't a tool that's publicly available that would allow you to delete the entire search index. If you need to do that, please open up a support case and we should be able to help you with that. However, there is a way to use templates to delete based on a query that may help. See my comments below.

For #2. Please feel free to open a support case for deleting a specific orphaned item in the index as well. However, if you do need some control on your end, what you could do is create a dummy template that includes the following code in the search_g2_insert.aspx and search_g2_update.aspx template files. You'll need to assign this template to a dummy asset as well since the search_g2_insert.aspx and serach_g2_update.aspx template files execute on a publish. 

var doc = new SearchG2JsonParams();
doc.Id = "<id here>";
doc.Operation = SearchG2JsonParams.OperationType.Delete;
context.JsonParams.Add(doc);

You'll need to replace <id here> with the id you're looking to delete. As mentioned you can also delete based off of a query with the following:

var doc = new SearchG2JsonParams();
doc.Query = "custom_s_test:\"cptest\"";
doc.Operation = SearchG2JsonParams.OperationType.Delete;
context.JsonParams.Add(doc);

The query assigned to the doc.Query property should be similar to the Solr Query syntax used to query the collection. 

View solution in original post

1 Reply
Highlighted
Crownpeak Employee
Crownpeak Employee

Re: Delete invalid asset from Index

Jump to solution

For #1. Unfortunately, there isn't a tool that's publicly available that would allow you to delete the entire search index. If you need to do that, please open up a support case and we should be able to help you with that. However, there is a way to use templates to delete based on a query that may help. See my comments below.

For #2. Please feel free to open a support case for deleting a specific orphaned item in the index as well. However, if you do need some control on your end, what you could do is create a dummy template that includes the following code in the search_g2_insert.aspx and search_g2_update.aspx template files. You'll need to assign this template to a dummy asset as well since the search_g2_insert.aspx and serach_g2_update.aspx template files execute on a publish. 

var doc = new SearchG2JsonParams();
doc.Id = "<id here>";
doc.Operation = SearchG2JsonParams.OperationType.Delete;
context.JsonParams.Add(doc);

You'll need to replace <id here> with the id you're looking to delete. As mentioned you can also delete based off of a query with the following:

var doc = new SearchG2JsonParams();
doc.Query = "custom_s_test:\"cptest\"";
doc.Operation = SearchG2JsonParams.OperationType.Delete;
context.JsonParams.Add(doc);

The query assigned to the doc.Query property should be similar to the Solr Query syntax used to query the collection. 

View solution in original post