Skip to content

Documents ids with slashes cause issues in high-level client #37405

@javanna

Description

@javanna

This issue was originated from #36988 . When using the high-level REST client to get/index/update documents, slashes in ids can cause problems. This has to do with the logic that encodes each url part separately and then puts the result together in RequestConverters. The following test fails while I think it should succeed. What I think happens at the moment is that the document gets indexed with a different id than the one provided.

public void testIdWithSlashes() throws IOException {
       IndexRequest indexRequest = new IndexRequest("dev_product");
       indexRequest.id("/sku/test.com/48923AQ3");
       indexRequest.source("field", "value");
       IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT);

       assertEquals("/sku/test.com/48923AQ3", indexResponse.getId());

       GetResponse getResponse = highLevelClient()
           .get(new GetRequest("dev_product", "/sku/test.com/48923AQ3"), RequestOptions.DEFAULT);
       assertTrue(getResponse.isExists());
   }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions