ThorbenJ / nrc-elasticsearch-nodes

A set of Node-RED contributed (NRC) nodes for Elasticsearch
MIT License
1 stars 0 forks source link

es-doc-create is missing id #4

Closed bidandows closed 1 year ago

bidandows commented 1 year ago

Hello there,

There is a problem when creating a document when not manually entering an "id"; this is the error message I am getting.

"es-doc-create is missing id"

I have read the documentation it's saying

DocID
{M} An optional doc ID, if absent one will be generated

But it's not working

BR

ThorbenJ commented 1 year ago

Hi. Thanks for reporting these. You are correct their is an incorrect assertion on line 36 of doc/create.js. Later when I have time to test I will push a new version. If you want you can try commenting out that line until then:

34:            
35:            if (!U.keyHasValue(node, params, 'index')) return;
36:            // if (!U.keyHasValue(node, params, 'id')) return;
37:            
38:            const client = node.conn.client();

I'll leave this open, until I get to push an updated version. BR, Thorben

bidandows commented 1 year ago

Hello @ThorbenJ , no worries I have created a function to generate a random UUID to be used as doc ID until you push the fix. I have also suggestion if possible to set an option to check to generate the doc ID as a random UUID when no value is set.

BR Abdnacer

ThorbenJ commented 1 year ago

HI.

The behaviour of the "create" node was correct, the documentation was not. The "_create" ES REST API always requires a doc ID. If you want to have ES generate an ID for you, use the "index" node, which uses the index API.

I have fixed the docs, improved some edge case handling. I also removed the erroneous warning from create index, as noted in issue #3. - Pushed in version 0.3.14

BR, Thorben

bidandows commented 1 year ago

Hello Thorben,

The update isn't working, I am getting the same error, after checking the node I found an error as you see in the screenshot.

image

ThorbenJ commented 1 year ago

The syntax error in index.js I had also noticed, but it the fix hadn't been committed - don't know why. It is fixed, but flows.nodered.org no longer auto updates. I just asked it to check npm again.

To be clear, "create" always need an ID, while "index" does not - This is intrinsic to Elasticsearch's API.