Skip to content

Commit

Permalink
#930 Filter unwanted fields from index/fields (#942)
Browse files Browse the repository at this point in the history
* #930 Filter unwanted fields from index/fields
* #930 Braces in wrong spot
* #930 revert a autocomplete #fail
* #930 skipFieldTypes overridable with config
  • Loading branch information
nickdos authored Jan 30, 2025
1 parent cc9794c commit 655bc72
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/au/org/ala/biocache/dao/SolrIndexDAOImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ public class SolrIndexDAOImpl implements IndexDAO {
"lastAssertionDate"
);

/*
* The field types to exclude from the index/fields JSON
*/
@Value("${index.fields.skipFieldTypes:location,geohash,quad,packedQuad}")
private final List<String> skipFieldTypes = new ArrayList<>();

/*
* This structure holds field properties
* Values in the list are:
Expand Down Expand Up @@ -671,10 +677,11 @@ private IndexFieldDTO formatIndexField(String fieldName, String fieldType, Strin

f.setName(fieldName);

if (fieldType != null) {
f.setDataType(fieldType);
if ((fieldType != null && skipFieldTypes.contains(fieldType)) || fieldName.startsWith("_")) {
// Skip fields we don't want to expose
return null;
} else {
f.setDataType("string");
f.setDataType(Objects.requireNonNullElse(fieldType, "string"));
}

if (distinctCount != null) {
Expand Down

0 comments on commit 655bc72

Please sign in to comment.