Skip to content

Commit

Permalink
#930 Filter unwanted fields from index/fields
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdos committed Jan 30, 2025
1 parent cc9794c commit 2c061a6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 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,16 @@ public class SolrIndexDAOImpl implements IndexDAO {
"lastAssertionDate"
);

/*
* The field types to exclude from the index/fields JSON
*/
private final List<String> skipFieldTypes = Arrays.asList(
"location",
"geohash",
"quad",
"packedQuad"
);

/*
* This structure holds field properties
* Values in the list are:
Expand Down Expand Up @@ -671,8 +681,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 if (fieldType != null) {
f.setDataType("date");
} else {
f.setDataType("string");
}
Expand Down

0 comments on commit 2c061a6

Please sign in to comment.