Search in sources :

Example 11 with FieldCapabilitiesResponse

use of org.opensearch.action.fieldcaps.FieldCapabilitiesResponse in project OpenSearch by opensearch-project.

the class FieldCapabilitiesIT method testWithUnmapped.

public void testWithUnmapped() {
    FieldCapabilitiesResponse response = client().prepareFieldCaps().setFields("new_field", "old_field").setIncludeUnmapped(true).get();
    assertIndices(response, "old_index", "new_index");
    assertEquals(2, response.get().size());
    assertTrue(response.get().containsKey("old_field"));
    Map<String, FieldCapabilities> oldField = response.getField("old_field");
    assertEquals(2, oldField.size());
    assertTrue(oldField.containsKey("long"));
    assertEquals(new FieldCapabilities("old_field", "long", true, true, new String[] { "old_index" }, null, null, Collections.emptyMap()), oldField.get("long"));
    assertTrue(oldField.containsKey("unmapped"));
    assertEquals(new FieldCapabilities("old_field", "unmapped", false, false, new String[] { "new_index" }, null, null, Collections.emptyMap()), oldField.get("unmapped"));
    Map<String, FieldCapabilities> newField = response.getField("new_field");
    assertEquals(1, newField.size());
    assertTrue(newField.containsKey("long"));
    assertEquals(new FieldCapabilities("new_field", "long", true, true, null, null, null, Collections.emptyMap()), newField.get("long"));
}
Also used : FieldCapabilities(org.opensearch.action.fieldcaps.FieldCapabilities) FieldCapabilitiesResponse(org.opensearch.action.fieldcaps.FieldCapabilitiesResponse)

Aggregations

FieldCapabilitiesResponse (org.opensearch.action.fieldcaps.FieldCapabilitiesResponse)11 FieldCapabilities (org.opensearch.action.fieldcaps.FieldCapabilities)5 FieldCapabilitiesRequest (org.opensearch.action.fieldcaps.FieldCapabilitiesRequest)4 ArrayList (java.util.ArrayList)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 IOException (java.io.IOException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ActionListener (org.opensearch.action.ActionListener)1 LatchedActionListener (org.opensearch.action.LatchedActionListener)1 GetMappingsResponse (org.opensearch.action.admin.indices.mapping.get.GetMappingsResponse)1 IndexRequestBuilder (org.opensearch.action.index.IndexRequestBuilder)1 RestHighLevelClient (org.opensearch.client.RestHighLevelClient)1 MappingMetadata (org.opensearch.cluster.metadata.MappingMetadata)1