Skip to content

Commit

Permalink
Add a collectionId field to the index
Browse files Browse the repository at this point in the history
This is either the last value in ancestorIds, or the itemId of the
item itself. The idea that we can collapse results on this value in
order to get only the highest item in a hierarchy.
  • Loading branch information
mikesname committed Mar 22, 2019
1 parent 4aa2033 commit db7ba38
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index-data-converter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>search-tools</artifactId>
<groupId>ehri-project</groupId>
<version>1.1.10</version>
<version>1.1.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,18 @@ public static Map<String, Object> postProcess(Map<String, Object> data) {
}
}

// HACK: Get a collection ID, which is either the last
// ID in ancestorIds or the ID of the item itself
// (if ancestor IDs is empty)
if (data.containsKey("ancestorIds")) {
Object ancestorIds = data.get("ancestorIds");
if (ancestorIds instanceof List && !((List)ancestorIds).isEmpty()) {
data.put("collectionId", ((List)ancestorIds).get(((List)ancestorIds).size() - 1));
} else {
data.put("collectionId", Lists.newArrayList(data.get("itemId")));
}
}

return data;
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>ehri-project</groupId>
<artifactId>search-tools</artifactId>
<packaging>pom</packaging>
<version>1.1.10</version>
<version>1.1.11</version>
<modules>
<module>solr-config</module>
<module>index-data-converter</module>
Expand Down
1 change: 1 addition & 0 deletions solr-config/core/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@
<field name="childCount" type="int" indexed="true" stored="true" default="0" multiValued="true"
required="false"/>
<field name="parentId" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="collectionId" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="ancestorIds" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="dateStart" type="date" indexed="true" stored="true" multiValued="false"/>
<field name="dateEnd" type="date" indexed="true" stored="true" multiValued="false"/>
Expand Down
2 changes: 1 addition & 1 deletion solr-config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>search-tools</artifactId>
<groupId>ehri-project</groupId>
<version>1.1.10</version>
<version>1.1.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down

0 comments on commit db7ba38

Please sign in to comment.