diff --git a/indexer/src/main/java/au/org/aodn/esindexer/service/AodnDiscoveryParameterVocabService.java b/indexer/src/main/java/au/org/aodn/esindexer/service/AodnDiscoveryParameterVocabService.java index 933a5579..53a77474 100644 --- a/indexer/src/main/java/au/org/aodn/esindexer/service/AodnDiscoveryParameterVocabService.java +++ b/indexer/src/main/java/au/org/aodn/esindexer/service/AodnDiscoveryParameterVocabService.java @@ -1,8 +1,9 @@ package au.org.aodn.esindexer.service; -import au.org.aodn.esindexer.utils.CacheArdcVocabsUtils; +import au.org.aodn.esindexer.utils.VocabsUtils; import au.org.aodn.stac.model.ConceptModel; import au.org.aodn.stac.model.ThemesModel; +import co.elastic.clients.elasticsearch.ElasticsearchClient; import com.fasterxml.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -15,7 +16,10 @@ @Service public class AodnDiscoveryParameterVocabService { @Autowired - CacheArdcVocabsUtils cacheArdcVocabsUtils; + VocabsUtils cacheArdcVocabsUtils; + + @Autowired + ElasticsearchClient portalElasticsearchClient; protected boolean themesMatchConcept(List themes, ConceptModel thatConcept) { for (ThemesModel theme : themes) { diff --git a/indexer/src/main/java/au/org/aodn/esindexer/service/IndexerServiceImpl.java b/indexer/src/main/java/au/org/aodn/esindexer/service/IndexerServiceImpl.java index 245e4100..411a8bc5 100644 --- a/indexer/src/main/java/au/org/aodn/esindexer/service/IndexerServiceImpl.java +++ b/indexer/src/main/java/au/org/aodn/esindexer/service/IndexerServiceImpl.java @@ -5,6 +5,7 @@ import au.org.aodn.esindexer.exception.*; import au.org.aodn.esindexer.utils.JaxbUtils; import au.org.aodn.metadata.iso19115_3_2018.*; +import au.org.aodn.stac.model.RecordSuggest; import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch._types.ElasticsearchException; import co.elastic.clients.elasticsearch.core.*; @@ -127,14 +128,21 @@ protected StacCollectionModel getMappedMetadataValues(String metadataValues) thr stacCollectionModel.getSummaries().setScore(score); - // TODO: in future, blah blah here - stacCollectionModel.setTitleSuggest(stacCollectionModel.getTitle()); - List aodnDiscoveryCategories = aodnDiscoveryParameterVocabService.getAodnDiscoveryCategories(stacCollectionModel.getThemes()); if (!aodnDiscoveryCategories.isEmpty()) { stacCollectionModel.getSummaries().setDiscoveryCategories(aodnDiscoveryCategories); } + + // categories suggest using a different index + + // extendable for other aspects of the records data. eg. title, description, etc. something that are unique to the record and currently using "text" type + RecordSuggest recordSuggest = RecordSuggest.builder() + .title(stacCollectionModel.getTitle()) + .description(null) // purely for demonstrating the extendability, manage extra suggest field in RecordSuggest class, and the index JSON schema + .build(); + stacCollectionModel.setRecordSuggest(recordSuggest); + return stacCollectionModel; } diff --git a/indexer/src/main/java/au/org/aodn/esindexer/utils/CacheArdcVocabsUtils.java b/indexer/src/main/java/au/org/aodn/esindexer/utils/VocabsUtils.java similarity index 98% rename from indexer/src/main/java/au/org/aodn/esindexer/utils/CacheArdcVocabsUtils.java rename to indexer/src/main/java/au/org/aodn/esindexer/utils/VocabsUtils.java index ac542813..4ae7da28 100644 --- a/indexer/src/main/java/au/org/aodn/esindexer/utils/CacheArdcVocabsUtils.java +++ b/indexer/src/main/java/au/org/aodn/esindexer/utils/VocabsUtils.java @@ -32,7 +32,7 @@ @Component // create and inject a stub proxy to self due to the circular reference http://bit.ly/4aFvYtt @Scope(proxyMode = ScopedProxyMode.TARGET_CLASS) -public class CacheArdcVocabsUtils { +public class VocabsUtils { @Value(AppConstants.AODN_DISCOVERY_PARAMETER_VOCAB_API) protected String vocabApi; @@ -41,7 +41,7 @@ public class CacheArdcVocabsUtils { // self-injection to avoid self-invocation problems when calling the cachable method within the same bean @Autowired - CacheArdcVocabsUtils self; + VocabsUtils self; @Autowired ElasticSearchIndexService elasticSearchIndexService; diff --git a/indexer/src/main/resources/config_files/aodn_discovery_parameter_vocabularies_index.json b/indexer/src/main/resources/config_files/aodn_discovery_parameter_vocabularies_index.json index a16e7731..953eaa5b 100644 --- a/indexer/src/main/resources/config_files/aodn_discovery_parameter_vocabularies_index.json +++ b/indexer/src/main/resources/config_files/aodn_discovery_parameter_vocabularies_index.json @@ -1,16 +1,28 @@ { + "settings":{ + "analysis":{ + "analyzer":{ + "custom_analyser":{ + "type":"custom", + "tokenizer":"standard", + "filter":[ + "lowercase", + "english_stop" + ] + } + }, + "filter":{ + "english_stop":{ + "type":"stop", + "stopwords":"_english_" + } + } + } + }, "mappings": { "dynamic": true, "properties": { - "label": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, + "label": { "type": "search_as_you_type", "analyzer": "custom_analyser" }, "definition": { "type": "text" }, @@ -20,15 +32,7 @@ "broader": { "type": "nested", "properties": { - "label": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, + "label": { "type": "text" }, "about": { "type": "keyword" } @@ -37,30 +41,14 @@ "narrower": { "type": "nested", "properties": { - "label": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, + "label": { "type": "text" }, "about": { "type": "keyword" }, "narrower": { "type": "nested", "properties": { - "label": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, + "label": { "type": "text" }, "about": { "type": "keyword" } diff --git a/indexer/src/main/resources/config_files/portal_records_index_schema.json b/indexer/src/main/resources/config_files/portal_records_index_schema.json index 69fa4d38..5cf3261f 100644 --- a/indexer/src/main/resources/config_files/portal_records_index_schema.json +++ b/indexer/src/main/resources/config_files/portal_records_index_schema.json @@ -29,9 +29,12 @@ "stac_version": { "type": "text" }, "type": { "type": "text" }, "title": { "type": "text" }, - "title_suggest": { - "type": "search_as_you_type", - "analyzer": "custom_analyser" + "record_suggest": { + "type": "nested", + "properties": { + "title": { "type": "search_as_you_type", "analyzer": "custom_analyser" }, + "description": { "type": "search_as_you_type", "analyzer": "custom_analyser" } + } }, "discovery_categories" : { "type": "keyword" }, "keywords": { diff --git a/indexer/src/test/java/au/org/aodn/esindexer/utils/AodnDiscoveryParameterVocabUtilsTest.java b/indexer/src/test/java/au/org/aodn/esindexer/utils/VocabUtilsTest.java similarity index 90% rename from indexer/src/test/java/au/org/aodn/esindexer/utils/AodnDiscoveryParameterVocabUtilsTest.java rename to indexer/src/test/java/au/org/aodn/esindexer/utils/VocabUtilsTest.java index e0f6b67a..2a153b4d 100644 --- a/indexer/src/test/java/au/org/aodn/esindexer/utils/AodnDiscoveryParameterVocabUtilsTest.java +++ b/indexer/src/test/java/au/org/aodn/esindexer/utils/VocabUtilsTest.java @@ -1,13 +1,10 @@ package au.org.aodn.esindexer.utils; -import au.org.aodn.ardcvocabs.configuration.ArdcAutoConfiguration; import au.org.aodn.esindexer.service.AodnDiscoveryParameterVocabService; import au.org.aodn.stac.model.ConceptModel; import au.org.aodn.stac.model.ThemesModel; import org.junit.jupiter.api.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; @@ -23,7 +20,7 @@ @ActiveProfiles("test") @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class AodnDiscoveryParameterVocabUtilsTest { +public class VocabUtilsTest { @Autowired AodnDiscoveryParameterVocabService aodnDiscoveryParameterVocabService; diff --git a/indexer/src/test/resources/canned/sample4_stac.json b/indexer/src/test/resources/canned/sample4_stac.json index 34f910ee..3adbf5eb 100644 --- a/indexer/src/test/resources/canned/sample4_stac.json +++ b/indexer/src/test/resources/canned/sample4_stac.json @@ -246,7 +246,9 @@ "title" : "AODN Discovery Parameter Vocabulary" } ], "id" : "7709f541-fc0c-4318-b5b9-9053aa474e0e", - "title_suggest" : "Ocean acidification historical reconstruction", + "record_suggest" : { + "title" : "Ocean acidification historical reconstruction" + }, "type" : "Collection", "stac_version" : "1.0.0", "stac_extensions" : [ "https://stac-extensions.github.io/scientific/v1.0.0/schema.json", "https://stac-extensions.github.io/contacts/v0.1.1/schema.json", "https://stac-extensions.github.io/projection/v1.1.0/schema.json", "https://stac-extensions.github.io/language/v1.0.0/schema.json", "https://stac-extensions.github.io/themes/v1.0.0/schema.json" ] diff --git a/stacmodel/src/main/java/au/org/aodn/stac/model/RecordSuggest.java b/stacmodel/src/main/java/au/org/aodn/stac/model/RecordSuggest.java new file mode 100644 index 00000000..934ae382 --- /dev/null +++ b/stacmodel/src/main/java/au/org/aodn/stac/model/RecordSuggest.java @@ -0,0 +1,11 @@ +package au.org.aodn.stac.model; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class RecordSuggest { + private String title; + private String description; +} diff --git a/stacmodel/src/main/java/au/org/aodn/stac/model/StacCollectionModel.java b/stacmodel/src/main/java/au/org/aodn/stac/model/StacCollectionModel.java index 0ac9ecb9..382c0837 100644 --- a/stacmodel/src/main/java/au/org/aodn/stac/model/StacCollectionModel.java +++ b/stacmodel/src/main/java/au/org/aodn/stac/model/StacCollectionModel.java @@ -14,8 +14,8 @@ public class StacCollectionModel { @JsonProperty("id") protected String uuid; protected String title; - @JsonProperty("title_suggest") - protected String titleSuggest; + @JsonProperty("record_suggest") + protected RecordSuggest recordSuggest; protected String description; protected ExtentModel extent; protected SummariesModel summaries;