diff --git a/src/main/kotlin/no/fdk/concept_catalog/service/ConceptSearchUtils.kt b/src/main/kotlin/no/fdk/concept_catalog/service/ConceptSearchUtils.kt index 3598f15..72bf8e9 100644 --- a/src/main/kotlin/no/fdk/concept_catalog/service/ConceptSearchUtils.kt +++ b/src/main/kotlin/no/fdk/concept_catalog/service/ConceptSearchUtils.kt @@ -8,6 +8,17 @@ fun SearchFilters.asQueryFilters(orgNumber: String): List { val queryFilters = mutableListOf(Query.of { queryBuilder -> queryBuilder.term { termBuilder -> termBuilder.field("ansvarligVirksomhet.id.keyword").value(orgNumber) } }) + + if (status != null) { + queryFilters + .add(Query.of { queryBuilder -> + queryBuilder.terms { termsBuilder -> + termsBuilder.field("statusURI.keyword") + .terms { fieldBuilder -> fieldBuilder.value(status.value.map { FieldValue.of(it) }) } + } + }) + } + if (published != null) { queryFilters.add(Query.of { queryBuilder -> queryBuilder.term { termBuilder -> @@ -55,8 +66,15 @@ fun SearchFilters.asQueryFilters(orgNumber: String): List { }) } -/* if (filters.subject != null) { - mongoQuery.addCriteria(Criteria.where("fagområdeKoder").`in`(filters.subject.value)) - }*/ + internalFields?.value?.forEach { (key, value) -> + queryFilters + .add(Query.of { queryBuilder -> + queryBuilder.terms { termsBuilder -> + termsBuilder.field("interneFelt.$key.value.keyword") + .terms { fieldBuilder -> fieldBuilder.value(value.map { FieldValue.of(it) }) } + } + }) + } + return queryFilters } diff --git a/src/test/kotlin/no/fdk/concept_catalog/contract/SearchConcepts.kt b/src/test/kotlin/no/fdk/concept_catalog/contract/SearchConcepts.kt index d352987..da23f67 100644 --- a/src/test/kotlin/no/fdk/concept_catalog/contract/SearchConcepts.kt +++ b/src/test/kotlin/no/fdk/concept_catalog/contract/SearchConcepts.kt @@ -17,7 +17,6 @@ import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.HttpMethod import org.springframework.http.HttpStatus import org.springframework.test.context.ContextConfiguration -import kotlin.test.Ignore import kotlin.test.assertEquals private val mapper = JacksonConfigurer().objectMapper() @@ -70,7 +69,6 @@ class SearchConcepts : ApiTestContext() { } @Test - @Ignore fun `Query returns correct results`() { val rsp = authorizedRequest( "/begreper/search?orgNummer=123456789", @@ -101,7 +99,6 @@ class SearchConcepts : ApiTestContext() { } @Test - @Ignore fun `Query with status filter returns correct results`() { val rsp = authorizedRequest( "/begreper/search?orgNummer=123456789", @@ -145,7 +142,6 @@ class SearchConcepts : ApiTestContext() { } @Test - @Ignore fun `Query with originalId filter returns correct results`() { val rsp = authorizedRequest( "/begreper/search?orgNummer=123456789", @@ -168,7 +164,6 @@ class SearchConcepts : ApiTestContext() { } @Test - @Ignore fun `Query with published filter returns correct results`() { val unPublishedResponse = authorizedRequest( "/begreper/search?orgNummer=123456789", @@ -233,7 +228,6 @@ class SearchConcepts : ApiTestContext() { } @Test - @Ignore fun `Query with internalFields filter returns correct results`() { val withInternalFieldsResponse = authorizedRequest( "/begreper/search?orgNummer=111222333", @@ -308,7 +302,6 @@ class SearchConcepts : ApiTestContext() { } @Test - @Ignore fun `Query filter with several values returns correct results`() { val rsp = authorizedRequest( "/begreper/search?orgNummer=123456789", @@ -337,7 +330,6 @@ class SearchConcepts : ApiTestContext() { } @Test - @Ignore fun `Query returns correct results when only title is active`() { val queryFields = QueryFields(definisjon = false, merknad = false, frarådetTerm = false, tillattTerm = false) val titleResponse = authorizedRequest( @@ -356,7 +348,7 @@ class SearchConcepts : ApiTestContext() { val descriptionResponse = authorizedRequest( "/begreper/search?orgNummer=123456789", port, - mapper.writeValueAsString(SearchOperation("able", fields = queryFields)), + mapper.writeValueAsString(SearchOperation("searchable", fields = queryFields)), JwtToken(Access.ORG_WRITE).toString(), HttpMethod.POST ) @@ -452,7 +444,6 @@ class SearchConcepts : ApiTestContext() { } @Test - @Ignore fun `Status filter returns correct results`() { val rsp = authorizedRequest( "/begreper/search?orgNummer=123456789", @@ -621,7 +612,6 @@ class SearchConcepts : ApiTestContext() { } @Test - @Ignore fun `Combination of status and published filter returns correct results`() { val rsp = authorizedRequest( "/begreper/search?orgNummer=123456789",