Adapt to Elasticsearch fix.

Original Pull Request #2302
Closes #2171
This commit is contained in:
Peter-Josef Meisch 2022-09-21 22:14:31 +02:00 committed by GitHub
parent 120ca8579f
commit eabde9c543
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 12 deletions

View File

@ -1252,9 +1252,15 @@ class RequestConverter {
Map<String, RuntimeField> runtimeMappings = new HashMap<>(); Map<String, RuntimeField> runtimeMappings = new HashMap<>();
query.getRuntimeFields() query.getRuntimeFields()
.forEach(runtimeField -> runtimeMappings.put(runtimeField.getName(), RuntimeField.of(rt -> rt // .forEach(runtimeField -> runtimeMappings.put(runtimeField.getName(), RuntimeField.of(runtimeFieldBuilder -> {
.type(RuntimeFieldType._DESERIALIZER.parse(runtimeField.getType())) // runtimeFieldBuilder.type(RuntimeFieldType._DESERIALIZER.parse(runtimeField.getType()));
.script(s -> s.inline(is -> is.source(runtimeField.getScript())))))); String script = runtimeField.getScript();
if (script != null) {
runtimeFieldBuilder.script(s -> s.inline(is -> is.source(script)));
}
return runtimeFieldBuilder;
})));
builder.runtimeMappings(runtimeMappings); builder.runtimeMappings(runtimeMappings);
} }

View File

@ -37,9 +37,4 @@ public class RuntimeFieldsELCIntegrationTests extends RuntimeFieldsIntegrationTe
return new IndexNameProvider("runtime-fields-rest-template"); return new IndexNameProvider("runtime-fields-rest-template");
} }
} }
@Override
public boolean newElasticsearchClient() {
return true;
}
} }

View File

@ -21,7 +21,6 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.NewElasticsearchClientDevelopment; import org.springframework.data.elasticsearch.NewElasticsearchClientDevelopment;
@ -41,7 +40,7 @@ import org.springframework.lang.Nullable;
* @author cdalxndr * @author cdalxndr
*/ */
@SpringIntegrationTest @SpringIntegrationTest
public abstract class RuntimeFieldsIntegrationTests implements NewElasticsearchClientDevelopment { public abstract class RuntimeFieldsIntegrationTests {
@Autowired private ElasticsearchOperations operations; @Autowired private ElasticsearchOperations operations;
@Autowired protected IndexNameProvider indexNameProvider; @Autowired protected IndexNameProvider indexNameProvider;
@ -61,7 +60,6 @@ public abstract class RuntimeFieldsIntegrationTests implements NewElasticsearchC
operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete(); operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete();
} }
@DisabledIf(value = "newElasticsearchClient", disabledReason = "todo #2171, ES issue 298")
@Test // #1971 @Test // #1971
@DisplayName("should use runtime-field from query in search") @DisplayName("should use runtime-field from query in search")
void shouldUseRuntimeFieldFromQueryInSearch() { void shouldUseRuntimeFieldFromQueryInSearch() {
@ -78,7 +76,6 @@ public abstract class RuntimeFieldsIntegrationTests implements NewElasticsearchC
assertThat(searchHits.getSearchHit(0).getId()).isEqualTo("2"); assertThat(searchHits.getSearchHit(0).getId()).isEqualTo("2");
} }
@DisabledIf(value = "newElasticsearchClient", disabledReason = "todo #2171, ES issue 298")
@Test // #2267 @Test // #2267
@DisplayName("should use runtime-field without script") @DisplayName("should use runtime-field without script")
void shouldUseRuntimeFieldWithoutScript() { void shouldUseRuntimeFieldWithoutScript() {