We have a site that has vairous membership restricted areas. Currently we are using Umbraco Examine to search the site, but we don't want to return results from pages that are not accessible by the current user.
Are the protected pages meant to be included in the index or not? Examine can be configured to include or exclude protected pages (by default they are excluded) but it doesn't flag them in any way to indicate that they are protected. This is by design and wont be changed in (at least, not in v1).
If you need them to be included in the same index as the unprotected pages you'll have to inject your own fields to indicate that they are protected or not. This can be done by adding a handler to the GatheringNodeData event on the BaseIndexProvider. This passes in a dictionary of fields that represents all the data, to include in the index. You can then add items to it if you need custom ones.
The it's just a matter of including the filter in your search.
However this throws a System.ArgumentNullException {"Value cannot be null.\r\nParameter name: umbracoContext"}
Presumably because the umbracoContext is stored in the HttpContext, which is null because the indexing is running on a separate thread without an HttpContext
Umbraco Examine - protected pages
Hi,
We have a site that has vairous membership restricted areas. Currently we are using Umbraco Examine to search the site, but we don't want to return results from pages that are not accessible by the current user.
Is this possible, and how would I go about it?
Thanks,
john.
Are the protected pages meant to be included in the index or not?
Examine can be configured to include or exclude protected pages (by default they are excluded) but it doesn't flag them in any way to indicate that they are protected. This is by design and wont be changed in (at least, not in v1).
If you need them to be included in the same index as the unprotected pages you'll have to inject your own fields to indicate that they are protected or not. This can be done by adding a handler to the GatheringNodeData event on the BaseIndexProvider. This passes in a dictionary of fields that represents all the data, to include in the index. You can then add items to it if you need custom ones.
The it's just a matter of including the filter in your search.
In my GatheringNodeData I wish to add isProtected info to the index , so I have code like so:
However this throws a System.ArgumentNullException {"Value cannot be null.\r\nParameter name: umbracoContext"}
Presumably because the umbracoContext is stored in the HttpContext, which is null because the indexing is running on a separate thread without an HttpContext
ahh, use this intead
is working on a reply...