Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Inconsistency for create index between REST and CreateIndex #12775

Open
amitgalitz opened this issue Mar 19, 2024 · 4 comments
Open

[BUG] Inconsistency for create index between REST and CreateIndex #12775

amitgalitz opened this issue Mar 19, 2024 · 4 comments
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing

Comments

@amitgalitz
Copy link
Member

Describe the bug

I am encountering inconsistencies between the rest API for create index and creating an index through the client in a plugin. When given the same mapping through the rest API create Index call and the client I get different responses. Specifically when using client.admin().indices().create(createIndexRequest… it fails if mappings doesn't have _doc in it with:

org.opensearch.index.mapper.MapperParsingException: Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [passage_text : {type=text}] [passage_embedding : {type=rank_features}] [id : {type=text}]

Related component

Indexing

To Reproduce

When I try to create a template with this mapping through REST API it works:

{
    "my-nlp-index": {
        "mappings": {
            "properties": {
                "id": {
                    "type": "text"
                },
                "passage_embedding": {
                    "type": "rank_features"
                },
                "passage_text": {
                    "type": "text"
                }
            }
        }
    }
}

however when I provide same mapping to:

CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName).source(configurationsBytes, XContentType.JSON);
            client.admin().indices().create(createIndexRequest, ActionListener.wrap(acknowledgedResponse -> { ...

I get this exception:

org.opensearch.index.mapper.MapperParsingException: Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [passage_text : {type=text}] [passage_embedding : {type=rank_features}] [id : {type=text}]

when I try to create a mapping with the _doc field below _mappings through rest

API it fails with:
{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "The mapping definition cannot be nested under a type"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "The mapping definition cannot be nested under a type"
    },
    "status": 400
}

however it succeeds with client.admin().indices().create(createIndexRequest…

Expected behavior

_doc shouldn't be required in 2.12 with client.admin().indices().create()

Additional Details

No response

@amitgalitz amitgalitz added bug Something isn't working untriaged labels Mar 19, 2024
@github-actions github-actions bot added the Indexing Indexing, Bulk Indexing and anything related to indexing label Mar 19, 2024
@dblock
Copy link
Member

dblock commented Mar 19, 2024

Do you have a quick repro, is it reproduced in the previously released version(s)?

@vikasvb90
Copy link
Contributor

Reason of inconsistency is due to the validation being present in rest layer and not in transport layer. Rest layer also wraps mapping properties with _doc here once it has validated that mappings object shouldn't have _doc field. Since, transport layer is now expecting _doc wrapped around properties of mappings, client call to create index fails if it doesn't have _doc.

In core, transport actions which rely on mappings, should be made backward compatible to wrap mapping properties with _doc if it isn't already present. These change(s) would be at cluster manager layer.

@vikasvb90 vikasvb90 removed the Indexing Indexing, Bulk Indexing and anything related to indexing label Mar 20, 2024
@andrross
Copy link
Member

[Triage - attendees 1 2 3 4 5 6]
@amitgalitz Thanks for filing.

@shwetathareja shwetathareja added the Indexing Indexing, Bulk Indexing and anything related to indexing label Mar 21, 2024
@sandeshkr419
Copy link
Contributor

sandeshkr419 commented Aug 5, 2024

@amitgalitz Did your PR address this issue? If yes, can we close this issue or are there any pending items left?

@rajiv-kv rajiv-kv moved this from 🆕 New to 🏗 In progress in Cluster Manager Project Board Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing
Projects
Status: 🏗 In progress
Development

No branches or pull requests

8 participants