Quick Search displays no results

Problem

Quick Search does not display any search results at all and restarting IIS does not resolve situation.

Log file indicates an error in creating the search index similar to: "This is impossible, presentation with id: XXX is of type YYY but did not exist in the YYY collection"


Extract from log may look like this

AssertWeb Verbose: 0 : 2017-09-29 08.10.03:OnActionExecuting:/en-US/<site>/Catalogue/<id>:Calling: https://www.domain.com/en-US/<site>/Catalogue/<id>
AssertWeb Error: 0 : 2017-09-29 08.10.03:<CreateSearchIndex>b__2b:/en-US/<site>/Search/Search?term=<term>:Failure during inserting search index entries
AssertWeb Error: 0 : System.NullReferenceException: This is impossible, presentation with id: 128 is of type part but did not exist in the part collection
   at Signifikant.Assert.Web.Viewer.Managers.SearchIndexProvider.<>c__DisplayClass32.<CreateSearchIndex>b__2b(Tuple`2 range)


Solution

The problem is in this case not the software but instead that the database is inconsistent. E.g .a presentation specifies that it is a part, but is something else. To resolve this issue, the database need to be corrected manually.


Warning!

Ensure to make a proper backup of the database before altering the database according to this guide or work on a copy of the database.


This is how to update type:

  1. The log file shows which presentation is inconsistent. E.g. This is impossible, presentation with id: 128.
  2. Use SQL to identify the presentation in the Presentations table.
  3. Look the TypeId and update the TypeId to the correct type.

This is how to figure out the type a presentation has:

  1. Use the below sql statement to find all TypeId.
    SELECT *  FROM [Assert4#AC].[dbo].[PresentationTypes] p left outer join dbo.TextTranslations t on t.TextId = p.NameId
  2. Base type is defined as below.
            public const int CatalogueId = 1;
            public const int IllustrationId = 2;
            public const int PartModuleId = 3;
            public const int DocumentId = 4;
            public const int PartId = 5;
            public const int ContentSetId = 6;
  3. The TypeId of the presentation may now be used to figure out what type the presentation has in the database.
  4. Now try to find the presentation in any of the following tables: Catalogues, Illustrations, PartModules, Documents, Parts, ContentSets. If presentation is e.g. found in Parts, it is now possible to conclude that TypeId is 5.
  5. Update the presentation and set TypeId to the new value.