I tested this locally by adding a boolean Hide from Elastic on a variant. In BuildIndexDocuments
I except all variants that are set to be hidden, before calling CreateModelsPerChannel
. Variants are excluded as expected.
When I rebuild the index the value is adhered to and if the value is false, the document is not created. If I change from Yes to No on the variant, it’s added as a document. Below is the bulk sent when going from Yes to No on 1 variant. All 3 variants are expected to be indexed.
POST http://localhost:9200/_bulk {"index":{"_id":"637471676729630133-06160105-0000-001cbd3f0fc-5fdc-44a7-8106-1d4fe0eddf31","_index":"761-rev2productdocument.en-us"}}
{"articleNumber":"637471676729630133-06160105-0000-001","assortments":["66dab9b4-9f2a-4fb7-8994-fcec2d6072ed"],"baseProductSystemId":"c2a56b74-9934-4dc8-837f-51f6bcdc4deb", ... }
{"index":{"_id":"637471676729630133-06160106-0000-001cbd3f0fc-5fdc-44a7-8106-1d4fe0eddf31","_index":"761-rev2productdocument.en-us"}}
{"articleNumber":"637471676729630133-06160106-0000-001","assortments":["66dab9b4-9f2a-4fb7-8994-fcec2d6072ed"],"baseProductSystemId":"c2a56b74-9934-4dc8-837f-51f6bcdc4deb", ... }
{"index":{"_id":"637471676729630133-06160107-0000-001_scbd3f0fc-5fdc-44a7-8106-1d4fe0eddf31","_index":"761-rev2productdocument.en-us"}}
{"articleNumber":"637471676729630133-06160107-0000-001_s","assortments":["66dab9b4-9f2a-4fb7-8994-fcec2d6072ed"],"baseProductSystemId":"c2a56b74-9934-4dc8-837f-51f6bcdc4deb", ... }
Going from No to Yes on 1 variant below. 2 variants are expected to be indexed.
POST http://localhost:9200/_bulk {"index":{"_id":"637471676729630133-06160105-0000-001cbd3f0fc-5fdc-44a7-8106-1d4fe0eddf31","_index":"761-rev2productdocument.en-us"}}
{"articleNumber":"637471676729630133-06160105-0000-001","assortments":["66dab9b4-9f2a-4fb7-8994-fcec2d6072ed"],"baseProductSystemId":"c2a56b74-9934-4dc8-837f-51f6bcdc4deb", ... }
{"index":{"_id":"637471676729630133-06160106-0000-001cbd3f0fc-5fdc-44a7-8106-1d4fe0eddf31","_index":"761-rev2productdocument.en-us"}}
{"articleNumber":"637471676729630133-06160106-0000-001","assortments":["66dab9b4-9f2a-4fb7-8994-fcec2d6072ed"],"baseProductSystemId":"c2a56b74-9934-4dc8-837f-51f6bcdc4deb", ... }
In neither case is any delete
called. If I remove the Where
clause from this (default Accelerator code):
foreach (var channel in channels).Where(x => !usedChannelSystemIds.Contains(x.SystemId)))
Now, I see one delete
per variant (+1 for base product), as expected. And switching between hidden / shown works.
POST http://localhost:9200/_bulk {"delete":{"_id":"637471676729630133-0616010cbd3f0fc-5fdc-44a7-8106-1d4fe0eddf31","_index":"761-rev2productdocument.en-us"}}
{"delete":{"_id":"637471676729630133-06160105-0000-001cbd3f0fc-5fdc-44a7-8106-1d4fe0eddf31","_index":"761-rev2productdocument.en-us"}}
{"delete":{"_id":"637471676729630133-06160106-0000-001cbd3f0fc-5fdc-44a7-8106-1d4fe0eddf31","_index":"761-rev2productdocument.en-us"}}
{"delete":{"_id":"637471676729630133-06160107-0000-001_Scbd3f0fc-5fdc-44a7-8106-1d4fe0eddf31","_index":"761-rev2productdocument.en-us"}}
{"index":{"_id":"637471676729630133-06160105-0000-001cbd3f0fc-5fdc-44a7-8106-1d4fe0eddf31","_index":"761-rev2productdocument.en-us"}}
{"articleNumber":"637471676729630133-06160105-0000-001","assortments":["66dab9b4-9f2a-4fb7-8994-fcec2d6072ed"],"baseProductSystemId":"c2a56b74-9934-4dc8-837f-51f6bcdc4deb", ... }
{"index":{"_id":"637471676729630133-06160106-0000-001cbd3f0fc-5fdc-44a7-8106-1d4fe0eddf31","_index":"761-rev2productdocument.en-us"}}
{"articleNumber":"637471676729630133-06160106-0000-001","assortments":["66dab9b4-9f2a-4fb7-8994-fcec2d6072ed"],"baseProductSystemId":"c2a56b74-9934-4dc8-837f-51f6bcdc4deb", ... }
{"index":{"_id":"637471676729630133-06160107-0000-001_scbd3f0fc-5fdc-44a7-8106-1d4fe0eddf31","_index":"761-rev2productdocument.en-us"}}
{"articleNumber":"637471676729630133-06160107-0000-001_s","assortments":["66dab9b4-9f2a-4fb7-8994-fcec2d6072ed"],"baseProductSystemId":"c2a56b74-9934-4dc8-837f-51f6bcdc4deb", ... }