Skip to content
Snippets Groups Projects
Commit aa68864f authored by Neelesh Thakur's avatar Neelesh Thakur
Browse files

add integration test of r3 schema

parent 7bd90d62
No related branches found
No related tags found
1 merge request!124add support for feature-collection indexing
......@@ -68,4 +68,10 @@ public class Steps extends SchemaServiceRecordSteps {
public void iShouldBeAbleToSearchRecordByTagKeyAndTagValue(int expectedNumber, String index, String tagKey, String tagValue) throws Throwable {
super.iShouldBeAbleToSearchRecordByTagKeyAndTagValue(index, tagKey, tagValue, expectedNumber);
}
@Then("^I should be able search (\\d+) documents for the \"([^\"]*)\" by bounding box query with points \\((-?\\d+), (-?\\d+)\\) and \\((-?\\d+), (-?\\d+)\\) on field \"(.*?)\"$")
public void i_should_get_the_documents_for_the_in_the_Elastic_Search_by_geoQuery (
int expectedCount, String index, Double topLatitude, Double topLongitude, Double bottomLatitude, Double bottomLongitude, String field) throws Throwable {
super.i_should_get_the_documents_for_the_in_the_Elastic_Search_by_geoQuery(expectedCount, index, topLatitude, topLongitude, bottomLatitude, bottomLongitude, field);
}
}
\ No newline at end of file
......@@ -109,7 +109,27 @@
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.8.1</version>
</dependency>
<dependency>
<groupId>org.locationtech.jts.io</groupId>
<artifactId>jts-io-common</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.locationtech.spatial4j</groupId>
<artifactId>spatial4j</artifactId>
<version>0.7</version>
</dependency>
<dependency>
<groupId>com.vividsolutions</groupId>
<artifactId>jts</artifactId>
<version>1.13</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--Logging-->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
......
......@@ -148,6 +148,14 @@ public class RecordSteps extends TestsBase {
assertEquals(expectedNumber, actualNumberOfRecords);
}
public void i_should_get_the_documents_for_the_in_the_Elastic_Search_by_geoQuery (
int expectedNumber, String index, Double topLatitude, Double topLongitude, Double bottomLatitude, Double bottomLongitude, String field) throws Throwable {
index = generateActualName(index, timeStamp);
long numOfIndexedDocuments = createIndex(index);
long actualNumberOfRecords = elasticUtils.fetchRecordsByBoundingBoxQuery(index, field, topLatitude, topLongitude, bottomLatitude, bottomLongitude);
assertEquals(expectedNumber, actualNumberOfRecords);
}
private long createIndex(String index) throws InterruptedException, IOException {
long numOfIndexedDocuments = 0;
int iterator;
......
......@@ -18,10 +18,12 @@
package org.opengroup.osdu.util;
import com.google.gson.Gson;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.SSLContext;
import lombok.extern.java.Log;
import org.apache.http.Header;
import org.apache.http.HttpHost;
......@@ -49,7 +51,8 @@ import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetMappingsRequest;
import org.elasticsearch.client.indices.GetMappingsResponse;
import org.elasticsearch.cluster.metadata.MappingMetadata;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.locationtech.jts.geom.Coordinate;
import org.elasticsearch.common.geo.builders.EnvelopeBuilder;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;
......@@ -65,8 +68,7 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.termsQuery;
import static org.elasticsearch.index.query.QueryBuilders.*;
/**
......@@ -255,6 +257,23 @@ public class ElasticUtils {
}
}
public long fetchRecordsByBoundingBoxQuery(String index, String field, Double topLatitude, Double topLongitude, Double bottomLatitude, Double bottomLongitude) throws Exception {
try (RestHighLevelClient client = this.createClient(username, password, host)) {
SearchRequest searchRequest = new SearchRequest(index);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
Coordinate topLeft = new Coordinate(topLongitude, topLatitude);
Coordinate bottomRight = new Coordinate(bottomLongitude, bottomLatitude);
searchSourceBuilder.query(boolQuery().must(geoWithinQuery(field, new EnvelopeBuilder(topLeft, bottomRight))));
searchRequest.source(searchSourceBuilder);
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
return searchResponse.getHits().getTotalHits().value;
} catch (ElasticsearchStatusException e) {
log.log(Level.INFO, String.format("Elastic search threw exception: %s", e.getMessage()));
return -1;
}
}
public Map<String, MappingMetadata> getMapping(String index) throws IOException {
try (RestHighLevelClient client = this.createClient(username, password, host)) {
GetMappingsRequest request = new GetMappingsRequest();
......
......@@ -3,10 +3,11 @@ Feature: Indexing of the documents
Background:
Given the schema is created with the following kind
| kind | index | schemaFile |
| tenant1:indexer-int-test:sample-schema-1:3.0.4 | tenant1-indexer-int-test:sample-schema-1-3.0.4 | index_records_1 |
| tenant1:indexer-int-test:sample-schema-2:2.0.4 | tenant1-indexer-int-test:sample-schema-2-2.0.4 | index_records_2 |
| tenant1:indexer-int-test:sample-schema-3:2.0.4 | tenant1-indexer-int-test:sample-schema-3-2.0.4 | index_records_3 |
| kind | index | schemaFile |
| tenant1:indexer-int-test:sample-schema-1:3.0.4 | tenant1-indexer-int-test:sample-schema-1-3.0.4 | index_records_1 |
| tenant1:indexer-int-test:sample-schema-2:2.0.4 | tenant1-indexer-int-test:sample-schema-2-2.0.4 | index_records_2 |
| tenant1:indexer-int-test:sample-schema-3:2.0.4 | tenant1-indexer-int-test:sample-schema-3-2.0.4 | index_records_3 |
| tenant1:indexer-int-test:master-data--test:1.0.2 | tenant1-indexer-int-test-master-data--test-1.0.2 | r3-index_record_wks_master |
Scenario Outline: Ingest the record and Index in the Elastic Search
When I ingest records with the <recordFile> with <acl> for a given <kind>
......@@ -34,3 +35,11 @@ Feature: Indexing of the documents
Examples:
| kind | recordFile | index | acl | tagKey | tagValue | number |
| "tenant1:indexer-int-test:sample-schema-1:3.0.4" | "index_records_1" | "tenant1-indexer-int-test-sample-schema-1-3.0.4" | "data.default.viewers@tenant1" | "testtag" | "testvalue" | 5 |
Scenario Outline: Ingest the r3-record with geo-shape and Index in the Elastic Search
When I ingest records with the <recordFile> with <acl> for a given <kind>
Then I should be able search <number> documents for the <index> by bounding box query with points (<top_left_latitude>, <top_left_longitude>) and (<bottom_right_latitude>, <bottom_right_longitude>) on field <field>
Examples:
| kind | recordFile | number | index | acl | field | top_left_latitude | top_left_longitude | bottom_right_latitude | bottom_right_longitude |
| "tenant1:indexer-int-test:master-data--test:1.0.2" | "r3-index_record_wks_master" | 1 | "tenant1-indexer-int-test-master-data--test-1.0.2" | ""data.default.viewers@tenant1" | "data.SpatialLocation.Wgs84Coordinates" | 52.0 | -100.0 | 0.0 | 100.0 |
[
{
"id": "tenant1:<kindSubType>:testIngest61<timestamp>",
"data": {
"NameAliases": [
{
"AliasName": "1001",
"AliasNameTypeID": "osdu:reference-data--AliasNameType:UWI:"
},
{
"AliasName": "AHM-01",
"AliasNameTypeID": "osdu:reference-data--AliasNameType:Borehole%20Code:"
},
{
"AliasName": "ARNHEM-01",
"AliasNameTypeID": "osdu:reference-data--AliasNameType:Borehole:"
}
],
"GeoContexts": [
{
"GeoPoliticalEntityID": "osdu:master-data--GeoPoliticalEntity:Gelderland:",
"GeoTypeID": "osdu:reference-data--GeoPoliticalEntityType:Province:"
},
{
"GeoPoliticalEntityID": "osdu:master-data--GeoPoliticalEntity:Lingewaard:",
"GeoTypeID": "osdu:reference-data--GeoPoliticalEntityType:Municipality:"
}
],
"SpatialLocation": {
"AsIngestedCoordinates": {
"type": "AnyCrsFeatureCollection",
"CoordinateReferenceSystemID": "osdu:reference-data--CoordinateReferenceSystem:ED_1950_UTM_Zone_31N:",
"features": [
{
"type": "AnyCrsFeature",
"geometry": {
"type": "AnyCrsPoint",
"coordinates": [
700113.0,
5757315.0
]
},
"properties": {}
}
],
"persistableReferenceCrs": ""
},
"Wgs84Coordinates": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
5.90929597,
51.92868061
]
},
"properties": {}
}
]
}
},
"InitialOperatorID": "osdu:master-data--Organisation:Bataafse%20Petroleum%20Maatschappij:",
"CurrentOperatorID": "osdu:master-data--Organisation:Nederlandse%20Aardolie%20Maatschappij%20B.V.:",
"OperatingEnvironmentID": "osdu:reference-data--OperatingEnvironment:ON:",
"FacilityStates": [
{
"FacilityStateTypeID": "osdu:reference-data--FacilityStateType:Abandoned:"
}
],
"FacilityEvents": [
{
"FacilityEventTypeID": "osdu:reference-data--FacilityEventType:Drilling%20Start:",
"EffectiveDateTime": "1944-03-01T00:00:00"
},
{
"FacilityEventTypeID": "osdu:reference-data--FacilityEventType:Drilling%20Finish:",
"EffectiveDateTime": "1944-10-02T00:00:00"
}
],
"WellID": "osdu:master-data--Well:1001:",
"SequenceNumber": 1,
"VerticalMeasurements": [
{
"VerticalMeasurementID": "TD-Original",
"VerticalMeasurement": 662.0,
"VerticalMeasurementTypeID": "osdu:reference-data--VerticalMeasurementType:Total%20Depth:",
"VerticalMeasurementPathID": "osdu:reference-data--VerticalMeasurementPath:Measured%20Depth:",
"VerticalMeasurementUnitOfMeasureID": "osdu:reference-data--UnitOfMeasure:M:",
"VerticalReferenceID": "Measured_From"
},
{
"VerticalMeasurementID": "TVD",
"VerticalMeasurement": 662.0,
"VerticalMeasurementTypeID": "osdu:reference-data--VerticalMeasurementType:TD:",
"VerticalMeasurementPathID": "osdu:reference-data--VerticalMeasurementPath:True%20Vertical%20Depth:",
"VerticalMeasurementUnitOfMeasureID": "osdu:reference-data--UnitOfMeasure:M:",
"VerticalReferenceID": "Measured_From"
},
{
"VerticalMeasurementID": "Measured_From",
"VerticalMeasurement": 11.01,
"VerticalMeasurementTypeID": "osdu:reference-data--VerticalMeasurementType:Rotary%20Table:",
"VerticalMeasurementPathID": "osdu:reference-data--VerticalMeasurementPath:Elevation:",
"VerticalMeasurementUnitOfMeasureID": "osdu:reference-data--UnitOfMeasure:M:",
"VerticalCRSID": "osdu:reference-data--CoordinateReferenceSystem:NAP:"
}
],
"DrillingReasons": [
{
"DrillingReasonTypeID": "osdu:reference-data--DrillingReasonType:EXP-HC:"
},
{
"DrillingReasonTypeID": "osdu:reference-data--DrillingReasonType:Exploratie%20koolwaterstof:"
}
],
"TrajectoryTypeID": "osdu:reference-data--WellboreTrajectoryType:Vertikaal:",
"PrimaryMaterialID": "osdu:reference-data--MaterialType:OIL:",
"ProjectedBottomHoleLocation": {
"AsIngestedCoordinates": {
"type": "AnyCrsFeatureCollection",
"CoordinateReferenceSystemID": "osdu:reference-data--CoordinateReferenceSystem:ED_1950_UTM_Zone_31N:",
"features": [
{
"type": "AnyCrsFeature",
"geometry": {
"type": "AnyCrsPoint",
"coordinates": [
700113.0,
5757315.0
]
},
"properties": {}
}
],
"persistableReferenceCrs": ""
}
}
}
}
]
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment