Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#930 Filter unwanted fields from index/fields #942

Merged
merged 4 commits into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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