Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • J 445 posts 862 karma points
    Aug 18, 2015 @ 15:22
    J
    1

    Umbraco site search options

    I have a basic Umbraco site which shows some of the products the client sells. No E-Commerce functionality or anything as such

    Is there a search component which i could use to search for the product which in turn returns a page showing the product page along with the image, price and description?

  • Ryios 122 posts 263 karma points
    Aug 18, 2015 @ 15:28
    Ryios
    1

    Umbraco use Examine,

    You can add a search index to your examine config file,

    e.g.

    <IndexSet SetName="ProductSearch" IndexPath="~/App_Data/TEMP/ExamineIndexes/ProductSearch/">
        <IndexAttributeFields>
            <add Name="id" />
            <add Name="nodeName" />       
            <add Name="updateDate" />
            <add Name="writerName" />
            <add Name="path" />
            <add Name="nodeTypeAlias" />
            <add Name="parentID" />
        </IndexAttributeFields>
        <IndexUserFields>
            <add Name="bodyText"/>
            <add Name="metaDescription"/>
            <add Name="metaTitle"/>
        </IndexUserFields>
        <IncludeNodeTypes>
            <add Name="TextPage"/>
        </IncludeNodeTypes>
        <ExcludeNodeTypes>
        </ExcludeNodeTypes>
    </IndexSet>
    

    What's important there is the IndexAttributeFields, these are property aliases on the document type you want to search on. And IncludeNodeTypes, these are the Document Type aliases (or media type aliases) that you want to show up in the search results. You can also explicitly exclude node types from the search results.

    Documentation here

    To use the search,

    var Searcher = ExamineManager.Instance.SearchProviderCollection["ProductSearch"];
    
    var query = searchCriteria.Field("nodeName","hello").Or().Field("metaTitle","hello").Compile();
    var searchResults = Searcher.Search(query);
    

    Then just transform your searchResults in ASPX or CSHTML (web forms or Razor w/e you are using).

Please Sign in or register to post replies

Write your reply to:

Draft