Smart Search Result Differ Drastically from Test Search in CMS

Michael Legacy asked on July 30, 2019 18:15

Hey all, I am seeing some weird stuff when implementing my search controller. If I test my index in Luke, it return pretty good relevant results. Same thing with the "Search Preview" section in Kentico itself. However, the real results using SearchHelper.Search() are not ideal and not matching the search preview.

Can someone help me understand what I'm doing wrong here? I have tried AnyWords, AnyWordsWithSynonyms for the search modes, and BasicSearch and FullSearch for the search options.

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using CLIENT.Models.Search;
using CMS.Helpers;
using CMS.Membership;
using CMS.Search;

namespace CLIENT.Controllers
public class SearchController : Controller

    // GET: Search
    public ActionResult Index()
        return View();

    public ActionResult Results(string q, string type, int page = 1)
        int skip = 0;
        int take = 10;
        if (page > 1)
            skip = ((page - 1) * take);

        q = HttpUtility.UrlDecode(q);

        if (String.IsNullOrWhiteSpace(q))
            // Creates a model representing empty search results
            SearchResultViewModel emptyModel = new SearchResultViewModel
                Items = new List<SearchResultItem>(),
                Query = String.Empty

            return View(emptyModel);

        DocumentSearchCondition docCondition = null;

        if (!String.IsNullOrWhiteSpace(type))

            docCondition = new DocumentSearchCondition(type, "en-us", "en-us", true);
        } else
            docCondition = null;

        // Gets the search index
        string indexes = "SiteIndex";

        SearchResultViewModel model = new SearchResultViewModel();

        var condition = new SearchCondition(null, SearchModeEnum.AnyWord, SearchOptionsEnum.BasicSearch, docCondition, true);
        string searchCondition = SearchSyntaxHelper.CombineSearchCondition(q, condition);

        if (indexes != null)
            // Prepares the search parameters
            SearchParameters parameters = new SearchParameters()
                SearchFor = searchCondition,
                SearchSort = "##SCORE##",
                Path = "/%",
                CurrentCulture = "EN-US",
                DefaultCulture = CultureHelper.EnglishCulture.IetfLanguageTag,
                CombineWithDefaultCulture = false,
                CheckPermissions = false,
                SearchInAttachments = false,
                User = (UserInfo)MembershipContext.AuthenticatedUser,
                SearchIndexes = indexes,
                StartingPosition = skip,
                DisplayResults = 10,
                NumberOfProcessedResults = 1000,
                NumberOfResults = 0,
                AttachmentWhere = String.Empty,
                AttachmentOrderBy = String.Empty,
                ClassNames = ""

            // Performs the search and returns the matching results as a SearchResult object
            //SearchResult countResult = SearchHelper.Search(countparameters);
            SearchResult results = SearchHelper.Search(parameters);

            model.PageSize = 10;
            model.CurrentPage = page;
            model.TotalItems = results.TotalNumberOfResults;
            model.Items = results.Items;
            model.Query = q;

        return View(model);

Correct Answer

Dmitry Bastron answered on July 30, 2019 18:28

Hi Michael,

Have you checked your search indexes are actually synchronized? When you use search preview functionality Kentico searches using Lucene index located in App_Data of CMS project. And MVC website searches through index located in App_Data in MVC project.

Internally, Kentico uses Web Farms to sync these indexes. Make sure there are no outstanding search tasks in Smart Search application first.

1 votesVote for this answer Unmark Correct answer

Recent Answers

Michael Legacy answered on July 30, 2019 19:05

That was it!

Next question basically is why the web farms aren't syncing.

I am getting the following in the Event Log:

Event ID: 270037
Event type: Error
Event time: 7/30/2019 12:51:34 PM
Source: WebFarmTaskProcessor
IP address:
Description: Web farm synchronization is currently disabled. You need a valid license that supports all your healthy web farm servers.
Machine name: DESKTOP-3S2INKM
Event URL:
URL referrer:
User agent:

We have an Ultimate License and these are local copies. We shouldn't be getting these license limitations. We have 3 developers working on this and we all share a remote database to keep all of our edits in sync while we build the site. Not sure if that's causing some sort of weird Web Farm issues.

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on July 30, 2019 19:14

Check the following settings in your local instance:

web farm settings

Also, your Web farm application shoukld show something like:

web farm

0 votesVote for this answer Mark as a Correct answer

Michael Legacy answered on July 30, 2019 19:21 (last edited on July 30, 2019 19:22)

Those settings are all set, here is what the Web Farm Application is telling me. Kind of odd...

Image Text

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on July 30, 2019 19:30

This picture is because you use single shared database between multiple devs I guess.

There are a couple more things I'd check:

  • If you use shared database, are all the devs using the same website domain names configured? localhost with the same port, for example. Also, you could try to make a local copy of the datase and connect only one dev machine and see if it helps with the sync.
  • Check that IIS app pool has wright permissions on App_Data folder for both CMS and MVC projects correspondingly.
0 votesVote for this answer Mark as a Correct answer

Michael Legacy answered on July 30, 2019 19:33

Will do, thanks for your help. At least we've narrowed the issue. I can probably figure out what's going on from here.

Thanks again!

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on July 30, 2019 19:40

You're welcome!

Also, you might check local Kentico Event log, there might be some errors helping to identify the issue.

If anything helps please mark as an answer. ;)

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.