The content service can perform slowly if you are using it to pull back large amounts of data, as it accesses the database directly.
The Umbraco helpers read from the Umbraco Cache file, but you need an Umbraco Context to be able to use them, and examine is probably running async, outside of the webrequest. UmbracoContect.Current will be null. The workaround is to 'ensure' a httpcontext:
if (UmbracoContext.Current == null)
{
var dummyHttpContext =
new HttpContextWrapper(
new HttpContext(new SimpleWorkerRequest("blah.aspx", "", new StringWriter())));
UmbracoContext.EnsureContext(
dummyHttpContext,
ApplicationContext.Current,
new WebSecurity(dummyHttpContext, ApplicationContext.Current),
UmbracoConfig.For.UmbracoSettings(),
UrlProviderResolver.Current.Providers,
false);
}
UmbracoHelper umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
But also you can access the fields of the item being indexed via the gathering nodes Event Args eg:
if (e.Fields.ContainsKey("myPropertyName")){
var myPropertyNameVariable = e.Fields["myPropertyName"];
}
Thanks for the HttpContext heads-up will give it a go.
This was my problem, I would use e.Fields, but there's an RTE field in there that has been stripped of it's html.
The whole point of using Examine here is for performance reasons - I don't at front-end run-time want to have to go back into the content cache to retrieve certain fields (html). (a lot of content, its a factor of 10 times slower than Lucene in my scenario).
So the idea was to include the unstripped html in the index. So i need to get at the raw property value.
var content = new Node(e.NodeId); seems to work just fine and for now there's no obsolete attribute on it, so...
Properties empty/erroring in GatheringNodeData
I saw a couple of posts that said in overriding Indexing via
GatheringNodeData
it was inefficient to use:but when I use
Many of the properties are erroring as object not set.
I've reverted to :
But that feels regressive.
Thoughts?
Hi Alastair
I guess it depends on what you are trying to do ?
The content service can perform slowly if you are using it to pull back large amounts of data, as it accesses the database directly.
The Umbraco helpers read from the Umbraco Cache file, but you need an Umbraco Context to be able to use them, and examine is probably running async, outside of the webrequest. UmbracoContect.Current will be null. The workaround is to 'ensure' a httpcontext:
But also you can access the fields of the item being indexed via the gathering nodes Event Args eg:
and then there is no additional lookup involved.
So it depends on what you are trying to do.
Thanks for the
HttpContext
heads-up will give it a go.This was my problem, I would use
e.Fields
, but there's an RTE field in there that has been stripped of it's html.The whole point of using Examine here is for performance reasons - I don't at front-end run-time want to have to go back into the content cache to retrieve certain fields (html). (a lot of content, its a factor of 10 times slower than Lucene in my scenario).
So the idea was to include the unstripped html in the index. So i need to get at the raw property value.
var content = new Node(e.NodeId);
seems to work just fine and for now there's no obsolete attribute on it, so...is working on a reply...