Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
Elasticsearch Services
Search Doc Service
Commits
c39f270a
Commit
c39f270a
authored
Dec 07, 2020
by
Jonas Waeber
Browse files
Change persons & places facet structure.
parent
c500825d
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/kotlin/builders/IFieldBuilder.kt
View file @
c39f270a
...
@@ -23,5 +23,5 @@ interface IFieldBuilder {
...
@@ -23,5 +23,5 @@ interface IFieldBuilder {
fun
filter
(
jsonObject
:
JsonObject
):
Boolean
fun
filter
(
jsonObject
:
JsonObject
):
Boolean
fun
append
(
key
:
String
,
jsonObject
:
JsonObject
):
String
fun
append
(
key
:
String
,
jsonObject
:
JsonObject
):
String
fun
build
():
List
<
Any
>
fun
build
():
Any
}
}
src/main/kotlin/builders/PersonFacetBuilder.kt
View file @
c39f270a
...
@@ -23,11 +23,13 @@ import com.beust.klaxon.JsonObject
...
@@ -23,11 +23,13 @@ import com.beust.klaxon.JsonObject
import
org.apache.logging.log4j.LogManager
import
org.apache.logging.log4j.LogManager
import
org.memobase.helpers.FacetBuildHelpers
import
org.memobase.helpers.FacetBuildHelpers
import
org.memobase.helpers.KEYS
import
org.memobase.helpers.KEYS
import
org.memobase.model.SimpleFacetContainer
class
PersonFacetBuilder
:
IFieldBuilder
{
class
PersonFacetBuilder
:
IFieldBuilder
{
private
val
log
=
LogManager
.
getLogger
(
"PersonFacetBuilder"
)
private
val
log
=
LogManager
.
getLogger
(
"PersonFacetBuilder"
)
private
val
personFacetValues
=
mutableSetOf
<
String
>()
private
val
personFacetValues
=
mutableSetOf
<
String
>()
private
val
personsNames
=
mutableSetOf
<
String
>()
override
fun
filter
(
jsonObject
:
JsonObject
):
Boolean
{
override
fun
filter
(
jsonObject
:
JsonObject
):
Boolean
{
return
jsonObject
[
KEYS
.
atType
].
let
{
return
jsonObject
[
KEYS
.
atType
].
let
{
...
@@ -41,6 +43,10 @@ class PersonFacetBuilder : IFieldBuilder {
...
@@ -41,6 +43,10 @@ class PersonFacetBuilder : IFieldBuilder {
override
fun
append
(
key
:
String
,
jsonObject
:
JsonObject
):
String
{
override
fun
append
(
key
:
String
,
jsonObject
:
JsonObject
):
String
{
val
result
=
FacetBuildHelpers
.
person
(
jsonObject
)
val
result
=
FacetBuildHelpers
.
person
(
jsonObject
)
return
if
(
result
.
second
.
isNotEmpty
())
{
return
if
(
result
.
second
.
isNotEmpty
())
{
result
.
first
.
let
{
if
(
it
!=
null
)
personsNames
.
add
(
it
)
}
personFacetValues
.
addAll
(
result
.
second
)
personFacetValues
.
addAll
(
result
.
second
)
""
""
}
else
{
}
else
{
...
@@ -50,7 +56,9 @@ class PersonFacetBuilder : IFieldBuilder {
...
@@ -50,7 +56,9 @@ class PersonFacetBuilder : IFieldBuilder {
}
}
}
}
override
fun
build
():
List
<
String
>
{
override
fun
build
():
SimpleFacetContainer
{
return
personFacetValues
.
toList
().
sortedBy
{
v
->
v
.
substring
(
2
)
}
return
SimpleFacetContainer
(
personFacetValues
.
toList
().
sortedBy
{
v
->
v
.
substring
(
2
)
},
personsNames
.
toList
().
sorted
())
}
}
}
}
src/main/kotlin/builders/PlaceFacetBuilder.kt
View file @
c39f270a
...
@@ -23,11 +23,13 @@ import com.beust.klaxon.JsonObject
...
@@ -23,11 +23,13 @@ import com.beust.klaxon.JsonObject
import
org.apache.logging.log4j.LogManager
import
org.apache.logging.log4j.LogManager
import
org.memobase.helpers.FacetBuildHelpers
import
org.memobase.helpers.FacetBuildHelpers
import
org.memobase.helpers.KEYS
import
org.memobase.helpers.KEYS
import
org.memobase.model.SimpleFacetContainer
class
PlaceFacetBuilder
:
IFieldBuilder
{
class
PlaceFacetBuilder
:
IFieldBuilder
{
private
val
log
=
LogManager
.
getLogger
(
"PersonFacetBuilder"
)
private
val
log
=
LogManager
.
getLogger
(
"PersonFacetBuilder"
)
private
val
placeFacetValues
=
mutableSetOf
<
String
>()
private
val
placeFacetValues
=
mutableSetOf
<
String
>()
private
val
placeNames
=
mutableSetOf
<
String
>()
override
fun
filter
(
jsonObject
:
JsonObject
):
Boolean
{
override
fun
filter
(
jsonObject
:
JsonObject
):
Boolean
{
return
jsonObject
[
KEYS
.
atType
].
let
{
return
jsonObject
[
KEYS
.
atType
].
let
{
...
@@ -41,6 +43,10 @@ class PlaceFacetBuilder : IFieldBuilder {
...
@@ -41,6 +43,10 @@ class PlaceFacetBuilder : IFieldBuilder {
override
fun
append
(
key
:
String
,
jsonObject
:
JsonObject
):
String
{
override
fun
append
(
key
:
String
,
jsonObject
:
JsonObject
):
String
{
val
result
=
FacetBuildHelpers
.
place
(
jsonObject
)
val
result
=
FacetBuildHelpers
.
place
(
jsonObject
)
return
if
(
result
.
second
.
isNotEmpty
())
{
return
if
(
result
.
second
.
isNotEmpty
())
{
result
.
first
.
let
{
if
(
it
!=
null
)
placeNames
.
add
(
it
)
}
placeFacetValues
.
addAll
(
result
.
second
)
placeFacetValues
.
addAll
(
result
.
second
)
""
""
}
else
{
}
else
{
...
@@ -50,7 +56,10 @@ class PlaceFacetBuilder : IFieldBuilder {
...
@@ -50,7 +56,10 @@ class PlaceFacetBuilder : IFieldBuilder {
}
}
}
}
override
fun
build
():
List
<
String
>
{
override
fun
build
():
SimpleFacetContainer
{
return
placeFacetValues
.
toList
().
sortedBy
{
v
->
v
.
substring
(
2
)
}
return
SimpleFacetContainer
(
placeFacetValues
.
toList
().
sortedBy
{
v
->
v
.
substring
(
2
)
},
placeNames
.
toList
().
sorted
()
)
}
}
}
}
src/main/kotlin/model/DocumentsSearchDoc.kt
View file @
c39f270a
...
@@ -20,6 +20,7 @@ package org.memobase.model
...
@@ -20,6 +20,7 @@ package org.memobase.model
import
com.fasterxml.jackson.annotation.JsonIgnore
import
com.fasterxml.jackson.annotation.JsonIgnore
import
com.fasterxml.jackson.annotation.JsonInclude
import
com.fasterxml.jackson.annotation.JsonInclude
import
org.memobase.model.SimpleFacetContainer.Companion
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
data class
DocumentsSearchDoc
(
data class
DocumentsSearchDoc
(
...
@@ -53,7 +54,7 @@ data class DocumentsSearchDoc(
...
@@ -53,7 +54,7 @@ data class DocumentsSearchDoc(
val
personContributor
:
List
<
AgentWithRelationContainer
>,
val
personContributor
:
List
<
AgentWithRelationContainer
>,
val
personPublisher
:
List
<
AgentWithRelationContainer
>,
val
personPublisher
:
List
<
AgentWithRelationContainer
>,
val
personProducer
:
List
<
AgentWithRelationContainer
>,
val
personProducer
:
List
<
AgentWithRelationContainer
>,
val
personsFacet
:
List
<
String
>
,
val
personsFacet
:
SimpleFacetContainer
,
val
corporateBodySubject
:
List
<
AgentWithRelationContainer
>,
val
corporateBodySubject
:
List
<
AgentWithRelationContainer
>,
val
corporateBodyCreator
:
List
<
AgentWithRelationContainer
>,
val
corporateBodyCreator
:
List
<
AgentWithRelationContainer
>,
...
@@ -70,7 +71,7 @@ data class DocumentsSearchDoc(
...
@@ -70,7 +71,7 @@ data class DocumentsSearchDoc(
// Places
// Places
val
placeRelated
:
List
<
FacetContainer
>,
val
placeRelated
:
List
<
FacetContainer
>,
val
placeCapture
:
List
<
FacetContainer
>,
val
placeCapture
:
List
<
FacetContainer
>,
val
placeFacet
:
List
<
String
>
,
val
placeFacet
:
SimpleFacetContainer
,
// Dates
// Dates
val
temporal
:
List
<
DateContainer
>,
val
temporal
:
List
<
DateContainer
>,
...
@@ -146,6 +147,7 @@ data class DocumentsSearchDoc(
...
@@ -146,6 +147,7 @@ data class DocumentsSearchDoc(
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
SimpleFacetContainer
.
EMPTY
,
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
...
@@ -158,8 +160,7 @@ data class DocumentsSearchDoc(
...
@@ -158,8 +160,7 @@ data class DocumentsSearchDoc(
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
SimpleFacetContainer
.
EMPTY
,
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
emptyList
(),
...
...
src/main/kotlin/model/SimpleFacetContainer.kt
0 → 100644
View file @
c39f270a
/*
* 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment