Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package au.org.aodn.ogcapi.server.core.service;

import au.org.aodn.ogcapi.features.model.FeatureCollectionGeoJSON;
import au.org.aodn.ogcapi.features.model.FeatureGeoJSON;
import au.org.aodn.ogcapi.server.core.model.EsFeatureCollectionModel;
import au.org.aodn.ogcapi.server.core.model.StacCollectionModel;
import au.org.aodn.ogcapi.server.core.model.StacItemModel;
import au.org.aodn.ogcapi.server.core.model.dto.SearchSuggestionsDto;
import au.org.aodn.ogcapi.server.core.model.enumeration.*;
import au.org.aodn.ogcapi.server.core.parser.elastic.CQLToElasticFilterFactory;
import au.org.aodn.ogcapi.server.core.parser.elastic.QueryHandler;
import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.FieldValue;
import co.elastic.clients.elasticsearch._types.aggregations.*;
import co.elastic.clients.elasticsearch._types.query_dsl.*;
import co.elastic.clients.elasticsearch.core.SearchMvtRequest;
import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.SearchResponse;
import co.elastic.clients.elasticsearch.core.search.Hit;
import co.elastic.clients.elasticsearch.core.search_mvt.GridType;
import co.elastic.clients.json.JsonData;
import co.elastic.clients.transport.endpoints.BinaryResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -29,12 +25,9 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StopWatch;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -398,6 +391,13 @@ protected static FieldValue toFieldValue(String s) {
Boolean v = Boolean.parseBoolean(s.trim());
return FieldValue.of(v);
}

if(s.trim().startsWith(STR_INDICATOR)) {
// UUID is part of the sort order, sometimes it will be an ID which is a
// number and can be parsed directly by code above, so to avoid incorrect parsing
// we will prefix it with STR_INDICATOR
return FieldValue.of(s.replaceFirst(STR_INDICATOR, "").trim());
}
// Assume it is string
return FieldValue.of(s.trim());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
@Slf4j
abstract class ElasticSearchBase {

protected static final String STR_INDICATOR = "str:";
protected Integer searchAsYouTypeSize;
protected String indexName;
protected Integer pageSize;
Expand Down Expand Up @@ -268,7 +269,7 @@ protected SearchResult<StacCollectionModel> searchCollectionBy(final List<Query>
} else if (value.isLong()) {
values.add(value.longValue());
} else if (value.isString()) {
values.add(value.stringValue());
values.add(STR_INDICATOR + value.stringValue());
}
}
result.setSortValues(values);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void verifyCorrectPageSizeDataReturn() throws IOException {
"search_after 2 arg"
);
assertEquals(
"bf287dfe-9ce4-4969-9c59-51c39ea4d011",
"str:bf287dfe-9ce4-4969-9c59-51c39ea4d011",
collections.getBody().getSearchAfter().get(2),
"search_after 3 arg"
);
Expand Down Expand Up @@ -219,7 +219,7 @@ public void verifyCorrectPageSizeDataReturnWithQuery() throws IOException {
// The search after give you the value to go to next batch
assertEquals(3, collections.getBody().getSearchAfter().size(), "search_after three fields");
assertEquals(
"bc55eff4-7596-3565-e044-00144fdd4fa6",
"str:bc55eff4-7596-3565-e044-00144fdd4fa6",
collections.getBody().getSearchAfter().get(2),
"search_after 2 arg"
);
Expand Down Expand Up @@ -248,7 +248,7 @@ public void verifyCorrectPageSizeDataReturnWithQuery() throws IOException {
// The search after give you the value to go to next batch
assertEquals(3, collections.getBody().getSearchAfter().size(), "search_after three fields");
assertEquals(
"5c418118-2581-4936-b6fd-d6bedfe74f62",
"str:5c418118-2581-4936-b6fd-d6bedfe74f62",
collections.getBody().getSearchAfter().get(2),
"search_after 3 arg"
);
Expand Down Expand Up @@ -277,7 +277,7 @@ public void verifyCorrectPageSizeDataReturnWithQuery() throws IOException {
// The search after give you the value to go to next batch
assertEquals(3, collections.getBody().getSearchAfter().size(), "search_after three fields");
assertEquals(
"bf287dfe-9ce4-4969-9c59-51c39ea4d011",
"str:bf287dfe-9ce4-4969-9c59-51c39ea4d011",
collections.getBody().getSearchAfter().get(2),
"search_after 3 value"
);
Expand Down Expand Up @@ -325,7 +325,7 @@ public void verifyCorrectPageSizeAndScoreWithQuery() throws IOException {
"search_after 2 value"
);
assertEquals(
"bc55eff4-7596-3565-e044-00144fdd4fa6",
"str:bc55eff4-7596-3565-e044-00144fdd4fa6",
collections.getBody().getSearchAfter().get(2),
"search_after 3 value"
);
Expand Down Expand Up @@ -354,7 +354,7 @@ public void verifyCorrectPageSizeAndScoreWithQuery() throws IOException {
// The search after give you the value to go to next batch
assertEquals(3, collections.getBody().getSearchAfter().size(), "search_after three fields");
assertEquals(
"bf287dfe-9ce4-4969-9c59-51c39ea4d011",
"str:bf287dfe-9ce4-4969-9c59-51c39ea4d011",
collections.getBody().getSearchAfter().get(2),
"Search after 2 value"
);
Expand Down