private void testSearchTerms(List<string> searchTerms,List<string> failures,SearchDTSearch searchDTSearch,string index,int skipRecordsCount)
{
if (searchTerms.Any())
{
try
{
using (SearchResults searchResults = searchDTSearch.Execute(index, searchTerms, null))
{
;//do nothing, we don't care about the results, just the fact that there was an error or not
}
}
catch (Exception ex)
{
if ((ex.Message != null) && (ex.Message.Contains("Operation failed: open (could not open directory)")))
{
LogManager.Warning("Attempt to test search term failed due to index access problem. Path of index used to test: '" + index + "'", ex);
}
else
{
//collect individual search terms with error
foreach (var searchTerm in searchTerms)
{
try
{
using (SearchResults searchResults = searchDTSearch.Execute(index, searchTerm, null))
{
;//do nothing, we don't care about the results, just the fact that there was an error or not
}
}
catch (Exception)
{
failures.Add(searchTerm);
}
}
}
}
finally
{
var dividedSearchTerms = searchTerms.Skip(skipRecordsCount).Take((searchTerms.Count/2)).ToList();
skipRecordsCount += dividedSearchTerms.Count();
this.testSearchTerms(dividedSearchTerms, failures, searchDTSearch, index, skipRecordsCount);
}
}
}
PS:不能更改Excute(),它需要List和string
PSS:不能在这里使用线程