|
16 | 16 | import org.junit.Before; |
17 | 17 |
|
18 | 18 | import java.io.IOException; |
| 19 | +import java.util.List; |
19 | 20 | import java.util.Map; |
20 | 21 |
|
21 | 22 | import static org.hamcrest.Matchers.equalTo; |
@@ -49,6 +50,25 @@ public void testWithInferenceNotConfigured() { |
49 | 50 | assertEquals(404, re.getResponse().getStatusLine().getStatusCode()); |
50 | 51 | } |
51 | 52 |
|
| 53 | + public void testCopyToWithSemanticText() throws IOException { |
| 54 | + assumeTrue("semantic text capability not available", EsqlCapabilities.Cap.SEMANTIC_TEXT_FIELD_CAPS.isEnabled()); |
| 55 | + |
| 56 | + var request = new Request("POST", "/test-semantic4/_doc/id-1"); |
| 57 | + request.addParameter("refresh", "true"); |
| 58 | + request.setJsonEntity("{\"text_field\": \"inference test\"}"); |
| 59 | + assertEquals(201, adminClient().performRequest(request).getStatusLine().getStatusCode()); |
| 60 | + |
| 61 | + ensureGreen("test-semantic4"); |
| 62 | + |
| 63 | + String query = """ |
| 64 | + from test-semantic4 |
| 65 | + """; |
| 66 | + Map<String, Object> result = runEsqlQuery(query); |
| 67 | + |
| 68 | + assertEquals(List.of("text_field", "semantic_text_field"), result.get("columns")); |
| 69 | + assertEquals(List.of("inference test", "inference test"), result.get("values")); |
| 70 | + } |
| 71 | + |
52 | 72 | @Before |
53 | 73 | public void setUpIndices() throws IOException { |
54 | 74 | var settings = Settings.builder().build(); |
@@ -82,6 +102,20 @@ public void setUpIndices() throws IOException { |
82 | 102 | } |
83 | 103 | """; |
84 | 104 | createIndex(adminClient(), "test-semantic3", settings, mapping3); |
| 105 | + |
| 106 | + String mapping4 = """ |
| 107 | + "properties": { |
| 108 | + "semantic_text_field": { |
| 109 | + "type": "semantic_text", |
| 110 | + "inference_id": "test_sparse_inference" |
| 111 | + }, |
| 112 | + "text_field": { |
| 113 | + "type": "text", |
| 114 | + "copy_to": "semantic_text_field" |
| 115 | + } |
| 116 | + } |
| 117 | + """; |
| 118 | + createIndex(adminClient(), "test-semantic4", settings, mapping4); |
85 | 119 | } |
86 | 120 |
|
87 | 121 | @Before |
|
0 commit comments