简体   繁体   中英

site search not working using Umbraco (ezsearch plugin)

I have installed ezsearch for site search in umbraco and rendered it as follow.

   @Umbraco.RenderMacro("ezSearch", new {rootContentNodeId="-1", rootMediaNodeId="-1", indexType="CONTENT", searchFields= "bodyText", previewFields="null", previewLength="null", pageSize="null", hideFromSearchField="null", searchFormLocation="null"})

It is not searching and always gives show now results. May be I am doing wrong with searchfields and prewiewfields. Any one having idea about this please help me,which values should i pass theough searchField and preview Fields thank you.

Ï had the exact same problem.

After digging around in the logs I found out that the ezsearch bootstrapper code (in app_code) was causing an error when indexing, since the item "contents" is allready beeing added to the index..

By commenting out these line from EzSearchBootstrapper.cs my indexes started populating again.

var combinedFields = new StringBuilder();
        foreach (var keyValuePair in e.Fields)
        {
            combinedFields.AppendLine(keyValuePair.Value);
        }
        e.Fields.Add("contents", combinedFields.ToString());

I'm running Umbraco 7.2.4 and ezsearch worked fine on all versions previous to this, but all of a sudden broke on this version. I was trying everything and finally got it to work by commenting out some of the query building code shown below, then it started working.

Obviously this has issues... You can try uncommenting some of the lines to find exactly where it breaks, but just thought I'd post this now.

This is in the ezsearch macro partial view fyi.

@* 
var contentPathFilter = model.RootContentNodeId > 0
            ? string.Format("__IndexType:{0} +searchPath:{1} -template:0", UmbracoExamine.IndexTypes.Content, model.RootContentNodeId)
            : string.Format("__IndexType:{0} -template:0", UmbracoExamine.IndexTypes.Content);
    var mediaPathFilter = model.RootMediaNodeId > 0
        ? string.Format("__IndexType:{0} +searchPath:{1}", UmbracoExamine.IndexTypes.Media, model.RootMediaNodeId)
        : string.Format("__IndexType:{0}", UmbracoExamine.IndexTypes.Media);

    switch (model.IndexType)
    {
        case UmbracoExamine.IndexTypes.Content:
            query.AppendFormat("+({0}) ", contentPathFilter);
            break;
        case UmbracoExamine.IndexTypes.Media:
            query.AppendFormat("+({0}) ", mediaPathFilter);
            break;
        default:
            query.AppendFormat("+(({0}) ({1})) ", contentPathFilter, mediaPathFilter);
            break;
    }
    *@

.....

@*  // Rank content based on positon of search terms in fields
    for (var i = 0; i < model.SearchFields.Count; i++)
    {
        foreach (var term in model.SearchTerms)
        {
            query.AppendFormat("{0}:{1}*^{2} ", model.SearchFields[i], term, model.SearchFields.Count - i);
        }
    }*@

Did you take a look at the documentation of EzSearch and did you try it using the macro inside the RTE instead of using it direct inside Razor. Inside the Documentation (PDF) there is a section called configuration here you can find some information about the configuration that can be done inside EzSearch.

Why are you giving all your parameters null where does it say that that can be done. I should suggest you take a look at the documentation and first try it with just

PreviewLength:

  • Type
    • int
  • Possible values
    • A positive integer
  • Description

    • Sets the maximum length of the preview text before it is concatenated. Concatenated preview text will be cropped at the last complete word and suffixed with ellipsis. The default value for PreviewLength is 250.

    @Umbraco.RenderMacro("ezSearch")

without any parameters. And from there add the parameters one by one and see when it actualy stops displaying anything.

Are you working inside visual studio or just Umbraco backend, when you are using visual studio it's a good thing to debug the application to see if it is throwing any exception. which will be catched by umbraco and swallowed. If not using Visual Studio take a look at the logging of Umbraco to see if there is some kind of error that is logged.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM