Skip to content

#2171-Adapt-to-Elasticsearch-fix #2302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
Expand Up @@ -1252,9 +1252,15 @@ private <T> void prepareSearchRequest(Query query, @Nullable Class<T> clazz, Ind

Map<String, RuntimeField> runtimeMappings = new HashMap<>();
query.getRuntimeFields()
.forEach(runtimeField -> runtimeMappings.put(runtimeField.getName(), RuntimeField.of(rt -> rt //
.type(RuntimeFieldType._DESERIALIZER.parse(runtimeField.getType())) //
.script(s -> s.inline(is -> is.source(runtimeField.getScript()))))));
.forEach(runtimeField -> runtimeMappings.put(runtimeField.getName(), RuntimeField.of(runtimeFieldBuilder -> {
runtimeFieldBuilder.type(RuntimeFieldType._DESERIALIZER.parse(runtimeField.getType()));
String script = runtimeField.getScript();

if (script != null) {
runtimeFieldBuilder.script(s -> s.inline(is -> is.source(script)));
}
return runtimeFieldBuilder;
})));
builder.runtimeMappings(runtimeMappings);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,4 @@ IndexNameProvider indexNameProvider() {
return new IndexNameProvider("runtime-fields-rest-template");
}
}

@Override
public boolean newElasticsearchClient() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.NewElasticsearchClientDevelopment;
Expand All @@ -41,7 +40,7 @@
* @author cdalxndr
*/
@SpringIntegrationTest
public abstract class RuntimeFieldsIntegrationTests implements NewElasticsearchClientDevelopment {
public abstract class RuntimeFieldsIntegrationTests {

@Autowired private ElasticsearchOperations operations;
@Autowired protected IndexNameProvider indexNameProvider;
Expand All @@ -61,7 +60,6 @@ void cleanup() {
operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete();
}

@DisabledIf(value = "newElasticsearchClient", disabledReason = "todo #2171, ES issue 298")
@Test // #1971
@DisplayName("should use runtime-field from query in search")
void shouldUseRuntimeFieldFromQueryInSearch() {
Expand All @@ -78,7 +76,6 @@ void shouldUseRuntimeFieldFromQueryInSearch() {
assertThat(searchHits.getSearchHit(0).getId()).isEqualTo("2");
}

@DisabledIf(value = "newElasticsearchClient", disabledReason = "todo #2171, ES issue 298")
@Test // #2267
@DisplayName("should use runtime-field without script")
void shouldUseRuntimeFieldWithoutScript() {
Expand Down