{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/32710","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/32710/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/32710/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/32710/events","html_url":"https://github.com/elastic/elasticsearch/issues/32710","id":348694199,"node_id":"MDU6SXNzdWUzNDg2OTQxOTk=","number":32710,"title":"Suggester throws error when it has 30 or more contexts","user":{"login":"leibale","id":7086055,"node_id":"MDQ6VXNlcjcwODYwNTU=","avatar_url":"https://avatars0.githubusercontent.com/u/7086055?v=4","gravatar_id":"","url":"https://api.github.com/users/leibale","html_url":"https://github.com/leibale","followers_url":"https://api.github.com/users/leibale/followers","following_url":"https://api.github.com/users/leibale/following{/other_user}","gists_url":"https://api.github.com/users/leibale/gists{/gist_id}","starred_url":"https://api.github.com/users/leibale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leibale/subscriptions","organizations_url":"https://api.github.com/users/leibale/orgs","repos_url":"https://api.github.com/users/leibale/repos","events_url":"https://api.github.com/users/leibale/events{/privacy}","received_events_url":"https://api.github.com/users/leibale/received_events","type":"User","site_admin":false},"labels":[{"id":146832564,"node_id":"MDU6TGFiZWwxNDY4MzI1NjQ=","url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Search/Search","name":":Search/Search","color":"0e8a16","default":false},{"id":23173,"node_id":"MDU6TGFiZWwyMzE3Mw==","url":"https://api.github.com/repos/elastic/elasticsearch/labels/%3Ebug","name":">bug","color":"b60205","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-08-08T11:57:37Z","updated_at":"2018-08-09T10:26:17Z","closed_at":"2018-08-09T10:26:17Z","author_association":"NONE","body":"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`.\r\n\r\n**Elasticsearch version**: 6.3.2\r\n\r\n**Steps to reproduce**:\r\nUse this `node.js` script to reproduce the bug\r\n\r\n```javascript\r\n(async () => {\r\n    const elasticSearch = require('elasticsearch'),\r\n        client = new elasticSearch.Client({\r\n            host: 'host'\r\n        }),\r\n        index = 'test-index';\r\n\r\n    async function _createIndex(numOfContexts) {\r\n        const numOfContextsArray = new Array(numOfContexts).fill(null);\r\n\r\n        await client.indices.delete({\r\n            index,\r\n            ignore: 404\r\n        });\r\n\r\n        await client.indices.create({\r\n            index,\r\n            body: {\r\n                mappings: {\r\n                    _doc: {\r\n                        properties: {\r\n                            ...numOfContextsArray.reduce((branchMappings, value, i) => {\r\n                                branchMappings[`property${i}`] = {\r\n                                    type: 'keyword'\r\n                                };\r\n                                return branchMappings;\r\n                            }, {}),\r\n                            suggest: {\r\n                                type: 'completion',\r\n                                contexts: numOfContextsArray.map((value, i) => ({\r\n                                    name: `context${i}`,\r\n                                    type: 'category',\r\n                                    path: `property${i}`\r\n                                }))\r\n                            }\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        });\r\n\r\n        await client.index({\r\n            index,\r\n            type: '_doc',\r\n            body: {\r\n                ...numOfContextsArray.reduce((branchMappings, value, i) => {\r\n                    branchMappings[`property${i}`] = 'value';\r\n                    return branchMappings;\r\n                }, {}),\r\n                suggest: ['test']\r\n            }\r\n        });\r\n    }\r\n\r\n    await _createIndex(29);\r\n    console.log('29 contexts is working');\r\n\r\n    try {\r\n        await _createIndex(30); // throwing an error\r\n    } catch (err) {\r\n        console.error(err);\r\n    }\r\n})();\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/411712162","html_url":"https://github.com/elastic/elasticsearch/issues/32710#issuecomment-411712162","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/32710","id":411712162,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMTcxMjE2Mg==","user":{"login":"jimczi","id":15977469,"node_id":"MDQ6VXNlcjE1OTc3NDY5","avatar_url":"https://avatars0.githubusercontent.com/u/15977469?v=4","gravatar_id":"","url":"https://api.github.com/users/jimczi","html_url":"https://github.com/jimczi","followers_url":"https://api.github.com/users/jimczi/followers","following_url":"https://api.github.com/users/jimczi/following{/other_user}","gists_url":"https://api.github.com/users/jimczi/gists{/gist_id}","starred_url":"https://api.github.com/users/jimczi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimczi/subscriptions","organizations_url":"https://api.github.com/users/jimczi/orgs","repos_url":"https://api.github.com/users/jimczi/repos","events_url":"https://api.github.com/users/jimczi/events{/privacy}","received_events_url":"https://api.github.com/users/jimczi/received_events","type":"User","site_admin":false},"created_at":"2018-08-09T10:26:16Z","updated_at":"2018-08-09T10:26:16Z","author_association":"MEMBER","body":"> How can I perform a suggest on the names when the product is active in a specific branch (like branches.${branchId}.isActive) without adding a context for each branch (each product has 40-50 branches)?\r\n\r\nSorry I misread your comment, if you only need to know if the suggestion is active in a branch you can use a single context mapping, `branch` for instance, and use the ids of the active branches as context values. So for instance if `product 1` is active in branches 1, 4 and 45 you can index it as:\r\n````\r\n{\r\n    \"suggest\": {\r\n        \"input\": \"product 1\",\r\n        \"contexts\": {\r\n            \"place_type\": [\"1\", \"4\", \"45\"] \r\n        }\r\n    }\r\n}\r\n````\r\nI opened https://github.com/elastic/elasticsearch/issues/32741 to address the >=30 contexts failures\r\n so I hope you don't mind if I close this issue. "}}
{"actor":{"display_login":"jimczi"}}