When creating buckets, I've always puzzled over one implementation decision from Sitecore in regards to buckets. By default, the bucket parent item is included in the list when you are searching for bucket items. Essentially my question is, WHY? It seems really strange. If I have a a product bucket with a bunch of product items in it, why wold I want to see the product bucket item come up in the results?

I'm aware that there is a setting to turn this off (BucketConfiguration.ExcludeContextItemFromResult) but I can't understand why that is set to false by default.

1 Answer 1


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);

enter image description here

Then; bucket config patches in bucket code to the AddFromTemplateCommand functionality on a Data Provider level.

  <database id="master">
      <obj type="Sitecore.Buckets.Commands.AddFromTemplateCommand, Sitecore.Buckets" />

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.

    <processor type="Sitecore.Buckets.Pipelines.BucketStatus.IsBucket.CheckIfItemIsABucket, Sitecore.Buckets"/>

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.