Skip to content
Merged
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 @@ -16,8 +16,11 @@
import org.junit.Before;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import static org.elasticsearch.test.ListMatcher.matchesList;
import static org.elasticsearch.test.MapMatcher.matchesMap;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.core.StringContains.containsString;

Expand Down Expand Up @@ -49,6 +52,27 @@ public void testWithInferenceNotConfigured() {
assertEquals(404, re.getResponse().getStatusLine().getStatusCode());
}

public void testCopyToWithSemanticText() throws IOException {
assumeTrue("semantic text capability not available", EsqlCapabilities.Cap.SEMANTIC_TEXT_FIELD_CAPS.isEnabled());

var request = new Request("POST", "/test-semantic4/_doc/id-1");
request.addParameter("refresh", "true");
request.setJsonEntity("{\"text_field\": \"inference test\"}");
assertEquals(201, adminClient().performRequest(request).getStatusLine().getStatusCode());

String query = """
from test-semantic4
""";
Map<String, Object> result = runEsqlQuery(query);

assertResultMap(
result,
matchesList().item(matchesMap().entry("name", "semantic_text_field").entry("type", "text"))
.item(matchesMap().entry("name", "text_field").entry("type", "text")),
List.of(List.of("inference test", "inference test"))
);
}

@Before
public void setUpIndices() throws IOException {
var settings = Settings.builder().build();
Expand Down Expand Up @@ -82,6 +106,20 @@ public void setUpIndices() throws IOException {
}
""";
createIndex(adminClient(), "test-semantic3", settings, mapping3);

String mapping4 = """
"properties": {
"semantic_text_field": {
"type": "semantic_text",
"inference_id": "test_dense_inference"
},
"text_field": {
"type": "text",
"copy_to": "semantic_text_field"
}
}
""";
createIndex(adminClient(), "test-semantic4", settings, mapping4);
}

@Before
Expand Down