We're definitely in the grey zone here; as not very many people can speculate on the reasoning that took place while this functionality was designed.
That said; the simpler the explanation the more likely it is.
When a bucket is created, all that really happens is the IsBucketItemCheckbox
field gets set to checked
using (new EditContext(parameter, SecurityCheck.Disable))
{
if (!parameter.IsBucketItemCheck())
parameter.IsBucketItemCheckBox().Checked = true;
Event.RaiseEvent("item:bucketing:ending", (object) parameters, (object) this);
Log.Info("Created Bucket Item for " + (object) parameter.ID, (object) this);
}
Then; bucket config patches in bucket code to the AddFromTemplateCommand
functionality on a Data Provider level.
<database id="master">
<Engines.DataEngine.Commands.AddFromTemplatePrototype>
<obj type="Sitecore.Buckets.Commands.AddFromTemplateCommand, Sitecore.Buckets" />
</Engines.DataEngine.Commands.AddFromTemplatePrototype>
</database>
Jumping through a few hoops and pipelines, essentially Sitecore will check the same checkbox for new items, if the parent item has the checkbox checked.
<buckets.isBucket>
<processor type="Sitecore.Buckets.Pipelines.BucketStatus.IsBucket.CheckIfItemIsABucket, Sitecore.Buckets"/>
</buckets.isBucket>
And the code
internal static bool IsBucketItemCheck(this Item item)
{
if (item != null && item.Fields[Sitecore.Buckets.Util.Constants.IsBucket] != null)
return item.Fields[Sitecore.Buckets.Util.Constants.IsBucket].Value.Equals("1");
return false;
}
(item, in this case, is the item the command is being invoked on - which would be the parent Item. Remember, new items are added via parent.Add()
)
And I believe that's all there is to it. The indexing code for buckets will index all items where the Is Bucket
field is checked and that's why you see your root node in results.
Unless you disable it, as you mention yourself.