Skip to content

Suggester throws error when it has 30 or more contexts #32710

Closed
@leibale

Description

@leibale

When indexing a document and there is a completion field with 30 or more contexts it throws an error Illegal value [\u001] UTF-16 codepoint [0x1d] at position 0 is a reserved character.

Elasticsearch version: 6.3.2

Steps to reproduce:
Use this node.js script to reproduce the bug

(async () => {
    const elasticSearch = require('elasticsearch'),
        client = new elasticSearch.Client({
            host: 'host'
        }),
        index = 'test-index';

    async function _createIndex(numOfContexts) {
        const numOfContextsArray = new Array(numOfContexts).fill(null);

        await client.indices.delete({
            index,
            ignore: 404
        });

        await client.indices.create({
            index,
            body: {
                mappings: {
                    _doc: {
                        properties: {
                            ...numOfContextsArray.reduce((branchMappings, value, i) => {
                                branchMappings[`property${i}`] = {
                                    type: 'keyword'
                                };
                                return branchMappings;
                            }, {}),
                            suggest: {
                                type: 'completion',
                                contexts: numOfContextsArray.map((value, i) => ({
                                    name: `context${i}`,
                                    type: 'category',
                                    path: `property${i}`
                                }))
                            }
                        }
                    }
                }
            }
        });

        await client.index({
            index,
            type: '_doc',
            body: {
                ...numOfContextsArray.reduce((branchMappings, value, i) => {
                    branchMappings[`property${i}`] = 'value';
                    return branchMappings;
                }, {}),
                suggest: ['test']
            }
        });
    }

    await _createIndex(29);
    console.log('29 contexts is working');

    try {
        await _createIndex(30); // throwing an error
    } catch (err) {
        console.error(err);
    }
})();

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Search/SearchSearch-related issues that do not fall into other categories>bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions