Skip to content

Commit

Permalink
Add collectionId and depth fields to the index
Browse files Browse the repository at this point in the history
The collectionId 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.

The depth field is the number of ancestors.
  • Loading branch information
mikesname committed Mar 22, 2019
1 parent 4aa2033 commit 994ea82
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 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,22 @@ 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 ancestors = (List) ancestorIds;
data.put("depth", ancestors.size());
if (!ancestors.isEmpty()) {
data.put("collectionId", ancestors.get(ancestors.size() - 1));
} else {
data.put("collectionId", Lists.newArrayList(data.get("itemId")));
}
}
}

return data;
}

Expand Down
1 change: 0 additions & 1 deletion index-data-converter/src/main/resources/paths.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ itemId=id
type=type
name=data.name
typeOfEntity=data.typeOfEntity
depthOfDescription=data.depthOfDescription
levelOfDescription=data.levelOfDescription
scope=data.scope
publicationStatus=data.publicationStatus
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
6 changes: 3 additions & 3 deletions solr-config/core/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,10 @@
<field name="type" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
<field name="itemId" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
<field name="gid" type="long" indexed="true" stored="true" multiValued="false" required="false"/>
<field name="childCount" type="int" indexed="true" stored="true" default="0" multiValued="true"
required="false"/>
<field name="depth" type="int" indexed="true" stored="true" default="0" required="false"/>
<field name="childCount" type="int" indexed="true" stored="true" default="0" 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 Expand Up @@ -339,7 +340,6 @@
<field name="languageCode" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="countryCode" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="countryName" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="depthOfDescription" type="int" indexed="true" stored="true"/>
<field name="levelOfDescription" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="languageOfMaterial" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="typeOfEntity" type="string" 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 994ea82

Please sign in to comment.