Search in sources :

Example 1 with RootObjectMapper

use of org.opensearch.index.mapper.RootObjectMapper in project OpenSearch by opensearch-project.

the class InternalEngineTests method dynamicUpdate.

private Mapping dynamicUpdate() {
    BuilderContext context = new BuilderContext(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(), new ContentPath());
    final RootObjectMapper root = new RootObjectMapper.Builder("some_type").build(context);
    return new Mapping(Version.CURRENT, root, new MetadataFieldMapper[0], emptyMap());
}
Also used : RootObjectMapper(org.opensearch.index.mapper.RootObjectMapper) BuilderContext(org.opensearch.index.mapper.Mapper.BuilderContext) Mapping(org.opensearch.index.mapper.Mapping) ContentPath(org.opensearch.index.mapper.ContentPath)

Example 2 with RootObjectMapper

use of org.opensearch.index.mapper.RootObjectMapper in project OpenSearch by opensearch-project.

the class MappingUpdatedActionTests method testSendUpdateMappingUsingAutoPutMappingAction.

public void testSendUpdateMappingUsingAutoPutMappingAction() {
    DiscoveryNodes nodes = DiscoveryNodes.builder().add(new DiscoveryNode("first", buildNewFakeTransportAddress(), LegacyESVersion.V_7_9_0)).build();
    ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).nodes(nodes).build();
    ClusterService clusterService = mock(ClusterService.class);
    when(clusterService.state()).thenReturn(clusterState);
    IndicesAdminClient indicesAdminClient = mock(IndicesAdminClient.class);
    AdminClient adminClient = mock(AdminClient.class);
    when(adminClient.indices()).thenReturn(indicesAdminClient);
    Client client = mock(Client.class);
    when(client.admin()).thenReturn(adminClient);
    MappingUpdatedAction mua = new MappingUpdatedAction(Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), clusterService);
    mua.setClient(client);
    Settings indexSettings = Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT).build();
    final Mapper.BuilderContext context = new Mapper.BuilderContext(indexSettings, new ContentPath());
    RootObjectMapper rootObjectMapper = new RootObjectMapper.Builder("name").build(context);
    Mapping update = new Mapping(LegacyESVersion.V_7_9_0, rootObjectMapper, new MetadataFieldMapper[0], Map.of());
    mua.sendUpdateMapping(new Index("name", "uuid"), update, ActionListener.wrap(() -> {
    }));
    verify(indicesAdminClient).execute(eq(AutoPutMappingAction.INSTANCE), any(), any());
}
Also used : ClusterState(org.opensearch.cluster.ClusterState) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) ClusterSettings(org.opensearch.common.settings.ClusterSettings) RootObjectMapper(org.opensearch.index.mapper.RootObjectMapper) IndicesAdminClient(org.opensearch.client.IndicesAdminClient) Mapping(org.opensearch.index.mapper.Mapping) Index(org.opensearch.index.Index) ContentPath(org.opensearch.index.mapper.ContentPath) Mapper(org.opensearch.index.mapper.Mapper) RootObjectMapper(org.opensearch.index.mapper.RootObjectMapper) MetadataFieldMapper(org.opensearch.index.mapper.MetadataFieldMapper) ClusterService(org.opensearch.cluster.service.ClusterService) ClusterName(org.opensearch.cluster.ClusterName) Client(org.opensearch.client.Client) AdminClient(org.opensearch.client.AdminClient) IndicesAdminClient(org.opensearch.client.IndicesAdminClient) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) ClusterSettings(org.opensearch.common.settings.ClusterSettings) Settings(org.opensearch.common.settings.Settings) AdminClient(org.opensearch.client.AdminClient) IndicesAdminClient(org.opensearch.client.IndicesAdminClient)

Example 3 with RootObjectMapper

use of org.opensearch.index.mapper.RootObjectMapper in project OpenSearch by opensearch-project.

the class MappingUpdatedActionTests method testSendUpdateMappingUsingPutMappingAction.

public void testSendUpdateMappingUsingPutMappingAction() {
    DiscoveryNodes nodes = DiscoveryNodes.builder().add(new DiscoveryNode("first", buildNewFakeTransportAddress(), LegacyESVersion.V_7_8_0)).build();
    ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).nodes(nodes).build();
    ClusterService clusterService = mock(ClusterService.class);
    when(clusterService.state()).thenReturn(clusterState);
    IndicesAdminClient indicesAdminClient = mock(IndicesAdminClient.class);
    AdminClient adminClient = mock(AdminClient.class);
    when(adminClient.indices()).thenReturn(indicesAdminClient);
    Client client = mock(Client.class);
    when(client.admin()).thenReturn(adminClient);
    MappingUpdatedAction mua = new MappingUpdatedAction(Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), clusterService);
    mua.setClient(client);
    Settings indexSettings = Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT).build();
    final Mapper.BuilderContext context = new Mapper.BuilderContext(indexSettings, new ContentPath());
    RootObjectMapper rootObjectMapper = new RootObjectMapper.Builder("name").build(context);
    Mapping update = new Mapping(LegacyESVersion.V_7_8_0, rootObjectMapper, new MetadataFieldMapper[0], Map.of());
    mua.sendUpdateMapping(new Index("name", "uuid"), update, ActionListener.wrap(() -> {
    }));
    verify(indicesAdminClient).putMapping(any(), any());
}
Also used : ClusterState(org.opensearch.cluster.ClusterState) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) ClusterSettings(org.opensearch.common.settings.ClusterSettings) RootObjectMapper(org.opensearch.index.mapper.RootObjectMapper) IndicesAdminClient(org.opensearch.client.IndicesAdminClient) Mapping(org.opensearch.index.mapper.Mapping) Index(org.opensearch.index.Index) ContentPath(org.opensearch.index.mapper.ContentPath) Mapper(org.opensearch.index.mapper.Mapper) RootObjectMapper(org.opensearch.index.mapper.RootObjectMapper) MetadataFieldMapper(org.opensearch.index.mapper.MetadataFieldMapper) ClusterService(org.opensearch.cluster.service.ClusterService) ClusterName(org.opensearch.cluster.ClusterName) Client(org.opensearch.client.Client) AdminClient(org.opensearch.client.AdminClient) IndicesAdminClient(org.opensearch.client.IndicesAdminClient) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) ClusterSettings(org.opensearch.common.settings.ClusterSettings) Settings(org.opensearch.common.settings.Settings) AdminClient(org.opensearch.client.AdminClient) IndicesAdminClient(org.opensearch.client.IndicesAdminClient)

Aggregations

ContentPath (org.opensearch.index.mapper.ContentPath)3 Mapping (org.opensearch.index.mapper.Mapping)3 RootObjectMapper (org.opensearch.index.mapper.RootObjectMapper)3 AdminClient (org.opensearch.client.AdminClient)2 Client (org.opensearch.client.Client)2 IndicesAdminClient (org.opensearch.client.IndicesAdminClient)2 ClusterName (org.opensearch.cluster.ClusterName)2 ClusterState (org.opensearch.cluster.ClusterState)2 DiscoveryNode (org.opensearch.cluster.node.DiscoveryNode)2 DiscoveryNodes (org.opensearch.cluster.node.DiscoveryNodes)2 ClusterService (org.opensearch.cluster.service.ClusterService)2 ClusterSettings (org.opensearch.common.settings.ClusterSettings)2 Settings (org.opensearch.common.settings.Settings)2 Index (org.opensearch.index.Index)2 Mapper (org.opensearch.index.mapper.Mapper)2 MetadataFieldMapper (org.opensearch.index.mapper.MetadataFieldMapper)2 BuilderContext (org.opensearch.index.mapper.Mapper.BuilderContext)1