I have a simple examine razor search and all was working on my dev pc but when I moved the site to the live environment it generates a razor script error on search
I've deleted the umbraco cache, deleted the search indexes but still no joy.
The thing that's making me mad, is that I'm breaking the query down, please see below
var term = Request["search"];
var searcher = ExamineManager.Instance.SearchProviderCollection["CorporateSearcher"];
var searchCriteria = searcher.CreateSearchCriteria();
var query = searchCriteria.Field("nodeName", term)
.Or().Field("bodyText", term)
.Or().Field("title", term)
.Or().Field("summary", term)
.Or().Field("pageName", term)
.Compile();
var results = searcher.Search(query).OrderBy(o => o.Score);
This will run fine, but I'll add a small piece of Html in and it suddenly stops. Once I remove the newly added code the whole thing generates an error.
I'd driving me crazy because I have a go live date. Any help would really be appreciated.
I'm not in work now until monday so don't have it to hand BUT!!!
Its the generic razor error message I get. I have just deployed to the staging server and then will be using courier to push the content live.
I have visual studio remote debugging tools going so that I can debug locally but whats strange is that it just jumps over the @Umbraco.RenderMarc("") when there is a problem.
I'd expect it to go into the macro and then probably error on a line. I've tried to break it down so strip everything out. I then build it back up slowly adding a line at a time.
It gets to a point that I put a basic html/razor syntax in and it breaks again, even when I remove the line its still broken.
I've been using Umbraco now for about 5 years and its got to be something silly happening but I just can't put my finger on it.
When the macro error occurs Umbraco will log the error in \app_data\logs\UmbracoTracelog.txt. The error message should be logged and this will give you a better idea of what is causing the error on staging.
You can also change the way that macro errors are handled. The UmbracoSettings.config file has an setting named macroErrors. By default Umbraco will use the inline option but you can change it to throw and this will result in an unhandled exception and YSOD (if customErrors is turned off)
Yes, we need to know what the actual error is. As noted by Dallas, the error should be in your log file, but you can also change your umbracoSettings.config setting:
<MacroErrors>throw</MacroErrors>
to be any of inline, silent or throw... putting it to 'throw' will show you the real ysod.
2015-07-06 12:30:27,238 [11] WARN umbraco.macro - [T38/D2] Error loading Partial View (file: ~/Views/MacroPartials/Search/SearchResults.cshtml). Exception: System.ApplicationException: Could not create an index searcher with the supplied lucene directory ---> Lucene.Net.Index.CorruptIndexException: doc counts differ for segment 0: fieldsReader shows 633 but segmentInfo shows 637
at Lucene.Net.Index.SegmentInfos.FindSegmentsFile.Run(IndexCommit commit)
at Lucene.Net.Index.DirectoryReader.Open(Directory directory, IndexDeletionPolicy deletionPolicy, IndexCommit commit, Boolean readOnly, Int32 termInfosIndexDivisor)
at Lucene.Net.Index.IndexReader.Open(Directory directory, IndexDeletionPolicy deletionPolicy, Boolean readOnly)
at Examine.LuceneEngine.Providers.LuceneSearcher.ValidateSearcher(Boolean forceReopen) in x:\Projects\Examine\Examine\Projects\Examine\LuceneEngine\Providers\LuceneSearcher.cs:line 311
--- End of inner exception stack trace ---
at Examine.LuceneEngine.Providers.LuceneSearcher.ValidateSearcher(Boolean forceReopen) in x:\Projects\Examine\Examine\Projects\Examine\LuceneEngine\Providers\LuceneSearcher.cs:line 412
at UmbracoExamine.UmbracoExamineSearcher.GetSearchFields()
at UmbracoExamine.UmbracoExamineSearcher.CreateSearchCriteria(String type, BooleanOperation defaultOperation)
at ASP.PageViewsMacroPartialsSearchSearchResults_cshtml.Execute() in d:\Websites\50014 - merthyr.gov.uk\Views\MacroPartials\Search\SearchResults.cshtml:line 21
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer)
at Umbraco.Web.Mvc.ControllerExtensions.RenderViewResultAsString(ControllerBase controller, ViewResultBase viewResult)
at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, IPublishedContent content)
at umbraco.macro.LoadPartialViewMacro(MacroModel macro)
at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
Did not know that about the macro inline option. Craig, in the backend are you able to view index manager or do you get errors there as well? If your still stuck you can skype me and screen share im on ismail_mayat
@Craig, most of the logging moved to the log files when log4net was added to Umbraco around v4.10. A lot of information gets logged to the file along with the errors and it can give some good insight into your Umbraco site.
Regarding the examine issue - I don't know what this particular error is but I would
Delete everything in the \App_Data\TEMP\ExamineIndexes directory (on the staging web server)
Go to the Developer section of Umbraco and use the Examine Management dashboard to rebuild the indexes
Throwing the error, and rebuilding the indexes I have now fixed the problem.
I have a multi project solution and it looks like one of the projects was referencing System.Web.Mvc 4.0.0.1 where my main Umbraco solution was using 4.0.0.0
It was causing other minor issues such as a razor listing page was working on dev but not on the staging site.
Apart from these very minor bits the site was running perfectly so didn't get picked up.
Examine issue thats driving me mad!!!!
I have a simple examine razor search and all was working on my dev pc but when I moved the site to the live environment it generates a razor script error on search
I've deleted the umbraco cache, deleted the search indexes but still no joy.
The thing that's making me mad, is that I'm breaking the query down, please see below
This will run fine, but I'll add a small piece of Html in and it suddenly stops. Once I remove the newly added code the whole thing generates an error.
I'd driving me crazy because I have a go live date. Any help would really be appreciated.
hi Craig
Can you provide the error message that you are getting? Is it an Examine error or a Razor error?
Dallas
Craig,
Not a fix but observation no need to orderyby score as your results are already ordered by lucene by score.
After moving to live I take it you rebuilt indexes?
Regards
Ismail
Hi Dallas,
I'm not in work now until monday so don't have it to hand BUT!!!
Its the generic razor error message I get. I have just deployed to the staging server and then will be using courier to push the content live.
I have visual studio remote debugging tools going so that I can debug locally but whats strange is that it just jumps over the @Umbraco.RenderMarc("") when there is a problem.
I'd expect it to go into the macro and then probably error on a line. I've tried to break it down so strip everything out. I then build it back up slowly adding a line at a time.
It gets to a point that I put a basic html/razor syntax in and it breaks again, even when I remove the line its still broken.
I've been using Umbraco now for about 5 years and its got to be something silly happening but I just can't put my finger on it.
Hi Ismail,
I was really hoping you would see the post :) Since copying the site over to the staging server I've:
It just doesn't make sense? What freaks me out it that I manage to have something that brings back the titles.
I then add an additional line e.g
result["BodyText"]
or something to bring back further fields and the whole things stops working.I then go and take this line back out but it still doesn't work
Hi Dallas/Ismail,
I created a small screenr video that shows my issue.
https://www.screenr.com/RdeN
The video shows the dev computer (mine windows 8) and the staging server (internal 2012)
I've just copied the whole directory from my computer to the staging server, including the web.config, so they are exact the same installs.
I'm completely stuck with this and thinking about throwing my computer through the window!!!!
Craig
When the macro error occurs Umbraco will log the error in \app_data\logs\UmbracoTracelog.txt. The error message should be logged and this will give you a better idea of what is causing the error on staging.
You can also change the way that macro errors are handled. The UmbracoSettings.config file has an setting named macroErrors. By default Umbraco will use the inline option but you can change it to throw and this will result in an unhandled exception and YSOD (if customErrors is turned off)
Dallas
Yes, we need to know what the actual error is. As noted by Dallas, the error should be in your log file, but you can also change your umbracoSettings.config setting:
to be any of inline, silent or throw... putting it to 'throw' will show you the real ysod.
Thanks both,
2015-07-06 12:30:27,238 [11] WARN umbraco.macro - [T38/D2] Error loading Partial View (file: ~/Views/MacroPartials/Search/SearchResults.cshtml). Exception: System.ApplicationException: Could not create an index searcher with the supplied lucene directory ---> Lucene.Net.Index.CorruptIndexException: doc counts differ for segment 0: fieldsReader shows 633 but segmentInfo shows 637 at Lucene.Net.Index.SegmentInfos.FindSegmentsFile.Run(IndexCommit commit) at Lucene.Net.Index.DirectoryReader.Open(Directory directory, IndexDeletionPolicy deletionPolicy, IndexCommit commit, Boolean readOnly, Int32 termInfosIndexDivisor) at Lucene.Net.Index.IndexReader.Open(Directory directory, IndexDeletionPolicy deletionPolicy, Boolean readOnly) at Examine.LuceneEngine.Providers.LuceneSearcher.ValidateSearcher(Boolean forceReopen) in x:\Projects\Examine\Examine\Projects\Examine\LuceneEngine\Providers\LuceneSearcher.cs:line 311 --- End of inner exception stack trace --- at Examine.LuceneEngine.Providers.LuceneSearcher.ValidateSearcher(Boolean forceReopen) in x:\Projects\Examine\Examine\Projects\Examine\LuceneEngine\Providers\LuceneSearcher.cs:line 412 at UmbracoExamine.UmbracoExamineSearcher.GetSearchFields() at UmbracoExamine.UmbracoExamineSearcher.CreateSearchCriteria(String type, BooleanOperation defaultOperation) at ASP.PageViewsMacroPartialsSearchSearchResults_cshtml.Execute() in d:\Websites\50014 - merthyr.gov.uk\Views\MacroPartials\Search\SearchResults.cshtml:line 21 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) at Umbraco.Web.Mvc.ControllerExtensions.RenderViewResultAsString(ControllerBase controller, ViewResultBase viewResult) at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, IPublishedContent content) at umbraco.macro.LoadPartialViewMacro(MacroModel macro) at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
This gives much more now :)
Dallas,
I'd checked the umbraco log table but never seem to go to the txt file which was excellent.
I'd also seen the config change but couldn't remember where I'd seen it, so another useful hint.
I normally just debug/trace everything through visual studio.
what is in your examine config files? Are you doing some sort of load balancing, etc... ? what version of Umbraco?
Dallas,
Did not know that about the macro inline option. Craig, in the backend are you able to view index manager or do you get errors there as well? If your still stuck you can skype me and screen share im on ismail_mayat
Regards
Ismail
Here they are and all looks fine
Ismail,
Just checked the examine management on the staging site and it shows
Examine Management Loading... Indexers
Searchers
@Craig, most of the logging moved to the log files when log4net was added to Umbraco around v4.10. A lot of information gets logged to the file along with the errors and it can give some good insight into your Umbraco site.
Regarding the examine issue - I don't know what this particular error is but I would
Dallas
I still need to know what version you are using, the more details you can provide, the easier/quicker it is to assist.
The dashboard will say that because it has JS errors, you'll need to see what those are in the developer console of the web browser you are using.
Dallas/Ismail/Shannon,
Really appreciate all the help guys, and think this is it.
I've got 3 days before holidays and the site goes live when I'm back, so its been stressing me out.
Also a couple of really useful tips.
Thanks All.
Throwing the error, and rebuilding the indexes I have now fixed the problem.
I have a multi project solution and it looks like one of the projects was referencing System.Web.Mvc 4.0.0.1 where my main Umbraco solution was using 4.0.0.0
It was causing other minor issues such as a razor listing page was working on dev but not on the staging site.
Apart from these very minor bits the site was running perfectly so didn't get picked up.
Again, thanks to all.
is working on a reply...