The code executes on page load if a query parameter is found on the querystring.
I step straight into this code and break on the last line shown here when I collect all the debug info using the Imediate Window.
var searchProvider = ExamineManager.Instance.SearchProviderCollection[SearchProviderName]; if (searchProvider == null) searchProvider = ExamineManager.Instance.DefaultSearchProvider;
var criteria = searchProvider.CreateSearchCriteria(IndexType.Content); criteria.RawQuery(q); var results = searchProvider.Search(criteria);
var summary = (from result in results select new { result.Id, result.Score, Title = result.Fields["nodeName"] }).ToList(); RecordCount = results.TotalItemCount; // break point here.
The results below to me they look like I've got a singleton of the inex that doesn't update unless I reload the application. (Similar to the issue I had earlier)
Here's the debug info for 5 queries, the first 3 use a "member-only" index, and the results change only when touching the web.config.
The second 2 use a "public" index, but the first results come from the "member-only" index until I touch the web.config again.
searchProvider.Name "KnowledgeForMembers" criteria.ToString() "{ MaxResults: 0, SearchIndexType: Content, LuceneQuery: +(abstract:lorem bodyText:lorem id:lorem nodeName:lorem updateDate:lorem writerName:lorem path:lorem nodeTypeAlias:lorem parentID:lorem) }" summary Count = 2 [0]: { Id = 1166, Score = 0.090463385, Title = "all attachments" } [1]: { Id = 1182, Score = 0.03762361, Title = "full article for members" } // here I update article #1182 to append v2 to the title.
searchProvider.Name "KnowledgeForMembers" criteria.ToString() "{ MaxResults: 0, SearchIndexType: Content, LuceneQuery: +(abstract:lorem bodyText:lorem id:lorem nodeName:lorem updateDate:lorem writerName:lorem path:lorem nodeTypeAlias:lorem parentID:lorem) }" summary Count = 2 [0]: { Id = 1166, Score = 0.090463385, Title = "all attachments" } [1]: { Id = 1182, Score = 0.03762361, Title = "full article for members" }
// touch web.config
searchProvider.Name "KnowledgeForMembers" criteria.ToString() "{ MaxResults: 0, SearchIndexType: Content, LuceneQuery: +(abstract:lorem bodyText:lorem id:lorem nodeName:lorem updateDate:lorem writerName:lorem path:lorem nodeTypeAlias:lorem parentID:lorem) }" summary Count = 2 [0]: { Id = 1166, Score = 0.090463385, Title = "all attachments" } [1]: { Id = 1182, Score = 0.03762361, Title = "full article for members v2" }
searchProvider.Name "KnowledgeForPublic" criteria.ToString() "{ MaxResults: 0, SearchIndexType: Content, LuceneQuery: +(abstract:lorem bodyText:lorem id:lorem nodeName:lorem updateDate:lorem writerName:lorem path:lorem nodeTypeAlias:lorem parentID:lorem) }" summary Count = 2 [0]: { Id = 1166, Score = 0.090463385, Title = "all attachments" } [1]: { Id = 1182, Score = 0.03762361, Title = "full article for members v2" }
Examine - Swapping Search Provider Name seems to 'cache' first used provider
I have the ability to search using different search providers.
The SearchProviderName is pulled out of an umbraco property, so it differs in the different sections that use search.
However it seems to get stuck on the first one used after the app loads.
Here's my code:
When/ where is the code executing?
Have you tried hitting a debugger to see what the name of the searchProvider object is?
I've got some working POC code for swapping providers on a per-request using an IoC container (and it worked :P)
The code executes on page load if a query parameter is found on the querystring.
I step straight into this code and break on the last line shown here when I collect all the debug info using the Imediate Window.
The results below to me they look like I've got a singleton of the inex that doesn't update unless I reload the application. (Similar to the issue I had earlier)
Here's the debug info for 5 queries, the first 3 use a "member-only" index, and the results change only when touching the web.config.
The second 2 use a "public" index, but the first results come from the "member-only" index until I touch the web.config again.
Hope I included enough info but not toooooo much :-)
Cheers.
Murray.
is working on a reply...