On 2017-05-22 02:25 AM, Derek Poh wrote:
Hi

Due to the source data structure, I need to concatenate the values of 2 fields ('supplier_id' and 'product_id') to form the unique 'id' of each document. However there are cases where some documents only have 'supplier_id' field. This will result in some documents with a longer/larger 'id' field (have both 'supplier_id' and 'product_id') and some with a shorter/smaller 'id' field value (has only 'supplier_id').

Please refer to simplified representation of the records below.
3rd record only has supplier id .
ts1 sup1 pdt1
ts1 sup1 pdt2
ts1 sup2
ts1 sup3 pdt3
ts1 sup4 pdt5
ts1 sup4 pdt6

I understand the unique 'id' is use during indexing to check whether a document already exists. Create if it does not exists else update if it exists.

Are there any implications if the unique 'id' field value is of different size/length among documents of a collection?
No
Is it advisable to have such design?
Derek
You need unique ID's. This design has the potential for (in error cases) concatenating id's incorrectly. It might be better to have ID's which are just a number. That said, my current project has ID's which are not just a number, YMMV.
cheers -- Rick

Derek

Reply via email to