In order to mitigate against the brute force attacks against Gitlab accounts, we are moving to all edu-ID Logins. We would like to remind you to link your account with your edu-id. Login will be possible only by edu-ID after November 30, 2021. Here you can find the instructions for linking your account.

If you don't have a SWITCH edu-ID, you can create one with this guide here

kind regards

This Server has been upgraded to GitLab release 14.2.6

Commit c39f270a authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Change persons & places facet structure.

parent c500825d
......@@ -23,5 +23,5 @@ interface IFieldBuilder {
fun filter(jsonObject: JsonObject): Boolean
fun append(key: String, jsonObject: JsonObject): String
fun build(): List<Any>
fun build(): Any
}
......@@ -23,11 +23,13 @@ import com.beust.klaxon.JsonObject
import org.apache.logging.log4j.LogManager
import org.memobase.helpers.FacetBuildHelpers
import org.memobase.helpers.KEYS
import org.memobase.model.SimpleFacetContainer
class PersonFacetBuilder : IFieldBuilder {
private val log = LogManager.getLogger("PersonFacetBuilder")
private val personFacetValues = mutableSetOf<String>()
private val personsNames = mutableSetOf<String>()
override fun filter(jsonObject: JsonObject): Boolean {
return jsonObject[KEYS.atType].let {
......@@ -41,6 +43,10 @@ class PersonFacetBuilder : IFieldBuilder {
override fun append(key: String, jsonObject: JsonObject): String {
val result = FacetBuildHelpers.person(jsonObject)
return if (result.second.isNotEmpty()) {
result.first.let {
if (it != null)
personsNames.add(it)
}
personFacetValues.addAll(result.second)
""
} else {
......@@ -50,7 +56,9 @@ class PersonFacetBuilder : IFieldBuilder {
}
}
override fun build(): List<String> {
return personFacetValues.toList().sortedBy { v -> v.substring(2) }
override fun build(): SimpleFacetContainer {
return SimpleFacetContainer(
personFacetValues.toList().sortedBy { v -> v.substring(2) },
personsNames.toList().sorted())
}
}
......@@ -23,11 +23,13 @@ import com.beust.klaxon.JsonObject
import org.apache.logging.log4j.LogManager
import org.memobase.helpers.FacetBuildHelpers
import org.memobase.helpers.KEYS
import org.memobase.model.SimpleFacetContainer
class PlaceFacetBuilder : IFieldBuilder {
private val log = LogManager.getLogger("PersonFacetBuilder")
private val placeFacetValues = mutableSetOf<String>()
private val placeNames = mutableSetOf<String>()
override fun filter(jsonObject: JsonObject): Boolean {
return jsonObject[KEYS.atType].let {
......@@ -41,6 +43,10 @@ class PlaceFacetBuilder : IFieldBuilder {
override fun append(key: String, jsonObject: JsonObject): String {
val result = FacetBuildHelpers.place(jsonObject)
return if (result.second.isNotEmpty()) {
result.first.let {
if (it != null)
placeNames.add(it)
}
placeFacetValues.addAll(result.second)
""
} else {
......@@ -50,7 +56,10 @@ class PlaceFacetBuilder : IFieldBuilder {
}
}
override fun build(): List<String> {
return placeFacetValues.toList().sortedBy { v -> v.substring(2) }
override fun build(): SimpleFacetContainer {
return SimpleFacetContainer(
placeFacetValues.toList().sortedBy { v -> v.substring(2) },
placeNames.toList().sorted()
)
}
}
......@@ -20,6 +20,7 @@ package org.memobase.model
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonInclude
import org.memobase.model.SimpleFacetContainer.Companion
@JsonInclude(JsonInclude.Include.NON_EMPTY)
data class DocumentsSearchDoc(
......@@ -53,7 +54,7 @@ data class DocumentsSearchDoc(
val personContributor: List<AgentWithRelationContainer>,
val personPublisher: List<AgentWithRelationContainer>,
val personProducer: List<AgentWithRelationContainer>,
val personsFacet: List<String>,
val personsFacet: SimpleFacetContainer,
val corporateBodySubject: List<AgentWithRelationContainer>,
val corporateBodyCreator: List<AgentWithRelationContainer>,
......@@ -70,7 +71,7 @@ data class DocumentsSearchDoc(
// Places
val placeRelated: List<FacetContainer>,
val placeCapture: List<FacetContainer>,
val placeFacet: List<String>,
val placeFacet: SimpleFacetContainer,
// Dates
val temporal: List<DateContainer>,
......@@ -146,6 +147,7 @@ data class DocumentsSearchDoc(
emptyList(),
emptyList(),
emptyList(),
SimpleFacetContainer.EMPTY,
emptyList(),
emptyList(),
emptyList(),
......@@ -158,8 +160,7 @@ data class DocumentsSearchDoc(
emptyList(),
emptyList(),
emptyList(),
emptyList(),
emptyList(),
SimpleFacetContainer.EMPTY,
emptyList(),
emptyList(),
emptyList(),
......
/*
* search-doc-service
* Copyright (C) 2020 Memoriav
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.memobase.model
import com.fasterxml.jackson.annotation.JsonInclude
@JsonInclude(JsonInclude.Include.NON_EMPTY)
data class SimpleFacetContainer(
val facet: List<String>,
val filter: List<String>
) {
companion object {
val EMPTY = SimpleFacetContainer(
emptyList(),
emptyList()
)
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment