Skip to content

Commit

Permalink
feat: add filters for label, subject and originalId
Browse files Browse the repository at this point in the history
  • Loading branch information
hegeaal committed Oct 6, 2023
1 parent 826074d commit f4bbcf1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,36 @@ fun SearchFilters.asQueryFilters(orgNumber: String): List<Query> {
}
})
}

if (originalId != null) {
queryFilters
.add(Query.of { queryBuilder ->
queryBuilder.terms { termsBuilder ->
termsBuilder.field("originaltBegrep.keyword")
.terms { fieldBuilder -> fieldBuilder.value(originalId.value.map { FieldValue.of(it) }) }
}
})
}

if (label != null) {
queryFilters
.add(Query.of { queryBuilder ->
queryBuilder.terms { termsBuilder ->
termsBuilder.field("merkelapp.keyword")
.terms { fieldBuilder -> fieldBuilder.value(label.value.map { FieldValue.of(it) }) }
}
})
}

if (subject != null) {
queryFilters
.add(Query.of { queryBuilder ->
queryBuilder.terms { termsBuilder ->
termsBuilder.field("fagområdeKoder")
.terms { fieldBuilder -> fieldBuilder.value(subject.value.map { FieldValue.of(it) }) }
}
})
}

return queryFilters
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ class SearchConcepts : ApiTestContext() {
}

@Test
@Ignore
fun `Query with subjects filter returns correct results`() {
val withSubjectFagomr1Response = authorizedRequest(
"/begreper/search?orgNummer=111222333",
Expand Down Expand Up @@ -272,7 +271,6 @@ class SearchConcepts : ApiTestContext() {
}

@Test
@Ignore
fun `Query with label filter returns correct results`() {
val withLabelResponse = authorizedRequest(
"/begreper/search?orgNummer=123456789",
Expand Down

0 comments on commit f4bbcf1

Please sign in to comment.