From d978728ae171cc82881354267261617cd5fa28d7 Mon Sep 17 00:00:00 2001 From: Mark Prins <1165786+mprins@users.noreply.github.com> Date: Tue, 14 Jan 2025 16:33:38 +0100 Subject: [PATCH] HTM-1413: when there are no attributes left indexing could crash becasue there are no fields to copy --- src/main/java/org/tailormap/api/solr/SolrHelper.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/tailormap/api/solr/SolrHelper.java b/src/main/java/org/tailormap/api/solr/SolrHelper.java index 85f629b11..7b3f5e14e 100644 --- a/src/main/java/org/tailormap/api/solr/SolrHelper.java +++ b/src/main/java/org/tailormap/api/solr/SolrHelper.java @@ -271,6 +271,12 @@ public SearchIndex addFeatureTypeIndex( Query q = new Query(fs.getName().toString()); // filter out any hidden properties (there should be none though) tmFeatureType.getSettings().getHideAttributes().forEach(propertyNames::remove); + if (propertyNames.isEmpty()) { + logger.warn("No valid properties to index for featuretype: {}, bailing out.", tmFeatureType.getName()); + return searchIndexRepository.save(searchIndex + .setStatus(SearchIndex.Status.ERROR) + .setSummary(summary.errorMessage("No valid properties to index"))); + } q.setPropertyNames(List.copyOf(propertyNames)); q.setStartIndex(0); // TODO: make maxFeatures configurable?