I am implementing Sitecore Item Buckets into my project for Sitecore 6.4, .NET 2.0.
I have everything installed and all appears to be working correctly. I created an item bucket and a bucketable template. The Search UI works perfectly in Content Editor queries. I can also query the index for my items in both Sitecore Index Viewer as well as the Sitecore Rocks Index utility.
However when I try to implement the UI in code, I can never get any results no matter what method I try. I keep getting null back for every type of query I try to run. I've tried BucketManager, Search extension method, and BucketQuery all to no avail.
I also have Debug logging turned on and when I search in Content Editor via the Search tab I see logging for the query, but when my code executes no log entries are generated whatsoever. Does anyone have an idea of why this may be happening. More than happy to provide more information to try and track this down.
Item root = MasterDatabase.GetItem(Constants.ARI_BUCKET_LOCATION_ID);
var items = root.Search(out hitCount,
text: "*",
indexName: "itembuckets_buckets",
location: root.ID.ToString(),
language: "en",
startDate: "01/01/2013",
endDate: "12/31/2013",
numberOfItemsToReturn: 100,
pageNumber: 1,
templates: tmpInventoryRate.ID.ToString());
var itemresults = root.Search(out hitCount, numberOfItemsToReturn: 100, language: "en");
var results = BucketManager.Search(root, out hitCount, templates: tmpInventoryRate.ID.ToString());
var textresults = BucketManager.Search(MasterDatabase.GetItem(Constants.ARI_BUCKET_LOCATION_PATH), out hitCount, text: "OEH", location: root.ID.ToString());
var pathresults = BucketManager.Search(MasterDatabase.GetItem(Constants.ARI_BUCKET_LOCATION_PATH), out hitCount, templates: tmpInventoryRate.ID.ToString());
var queryresults = new BucketQuery().WhereTemplateIs("*").Run(root, 100);
One thing to note that I am curious about is that the above code executes in a DAL module that does not have access to Sitecore.Context but the MasterDatabase.GetItem() call does in fact retrieve the Item from the master database, but I don't know if somewhere in the Bucket API code Context is being referenced potentially?