Copied to clipboard

Flag this post as spam?

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


  • Dan 1288 posts 3921 karma points c-trib
    Jan 20, 2012 @ 13:19
    Dan
    0

    Prevent Examine indexing images

    Hi,

    I have a site search which needs to search several document types and some properties of the file media type.  I've set up an index like this:

    <IndexSet SetName="SiteSearchIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/SiteSearch/">
            <IndexAttributeFields>
                <add Name="id" />
                <add Name="nodeName"/>
                <add Name="updateDate" />
                <add Name="writerName" />
                <add Name="loginName" />
                <add Name="email" />
                <add Name="nodeTypeAlias" />
            </IndexAttributeFields>
            <IndexUserFields>
                <add Name="pageTitle" />
                <add Name="metaKeywords" />
                <add Name="metaDescription" />
                <add Name="mainContent" />
                <add Name="introText" />
                <add Name="mainText" />
                <add Name="title" />
                <add Name="reference" />
                <add Name="keyWords" />
            </IndexUserFields>
            <IncludeNodeTypes>
                <add Name="File" />
                <add Name="GeneralTextPage" />
                <add Name="GridOfSubPages" />
                <add Name="Home" />
                <add Name="ListingOfSubPages" />
                <add Name="NewsArticle" />
                <add Name="NewsSection" />
                <add Name="SubPage" />
            </IncludeNodeTypes>
            <ExcludeNodeTypes>
                <add Name="Image" />
                <add Name="Folder" />
            </ExcludeNodeTypes>   
        </IndexSet>

    However, the search results are still returning images from the media section - despite me including the 'Image' media type in the excluded node type.  I can filter these out pretty easily with the Razor script but would rather understand why they're being returned to begin with.

    Does anyone know if this is a bug or are my config settings not right?

    Thanks folks!

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jan 20, 2012 @ 17:13
    Ismail Mayat
    0

    Dan,

    In theory it should not index image and folder. Can you paste your examine search code if you set the indextype to content then that will ignore media items from the search.

    Regards

    Ismail

  • Dan 1288 posts 3921 karma points c-trib
    Jan 20, 2012 @ 17:31
    Dan
    0

    Hi Ismail,

    A little rough around the edges but here's the Razor code.  It's not a straight forward search as it's searching both content nodes and media nodes (of type 'File' only - not images or folders).  It also requires that members are logged in if they are to be able to see the file download links, otherwise they still get the search result but with a prompt to log in rather than a download link.  It works great except for the fact that it's showing image media items in the search results.  I've tried deleting the examine index and restarting the app pool etc but it still throws up images in the search results.

    @using Examine;
    @using umbraco;


    @helper Truncate(string input,int length)
    {
        if(input.Length<=length){
            @Html.Raw(input)
        }else{
            @Html.Raw(input.Substring(0,length))<text>...</text>
        }
    }


    @{var searchTerm = Request.Form["search"];}


      @if (searchTerm != ""){
        <h2>Showing @ExamineManager.Instance.Search(searchTerm, true).Count() results for @searchTerm</h2>
        <div class="search-results">
          @foreach (var result in ExamineManager.Instance.Search(searchTerm, true)) {
            if (result.Fields["nodeTypeAlias"] == "File"){                                
              if (library.IsLoggedOn()) {
                <article>
                  <h3><a href="@result.Fields["umbracoFile"]" title="Download file" target="_blank">@result.Fields["nodeName"]</a></h3>
                  @if (result.Fields.ContainsKey("fileTitle"))
                  {
                    <p>@result.Fields["fileTitle"]</p>
                  }
                  <p class="link"><a href="@result.Fields["umbracoFile"]" title="Download file" target="_blank">Download file</a></p>
                </article>
              } else {
                <article>
                  <h3>@result.Fields["nodeName"]</h3>
                  @if (result.Fields.ContainsKey("fileTitle"))
                  {
                    <p>@result.Fields["fileTitle"]</p>
                  }
                  <p class="link">You must <a href="@umbraco.library.NiceUrl(1162)" title="">log in</a> to view this document</p>
                </article>
              }
            }
            else
            {
              <article>
                <h3><a href="@umbraco.library.NiceUrl(result.Id)" title="@result.Fields["nodeName"]">@result.Fields["nodeName"]</a></h3>
                @if (result.Fields.ContainsKey("mainContent"))
                {
                  <p>@Truncate(result.Fields["mainContent"],200)</p>
                }
                <p class="link">
                  <a href="@umbraco.library.NiceUrl(result.Id)">
                    @umbraco.library.NiceUrl(result.Id)
                  </a>
                </p>
              </article>
            }
          }
        </div>
      }

    Any ideas?

    (This is a clean 4.7.1 install by the way - not an upgrade and not 4.7.1.1).

  • Vladimir Knobel 95 posts 171 karma points
    Jun 30, 2012 @ 18:42
    Vladimir Knobel
    0

    You should use SearchProviderCollection like stated in this post: 

    http://our.umbraco.org/forum/using/ui-questions/25608-Using-examine-search

    Hope this helps someone

  • Harish 15 posts 74 karma points
    Nov 20, 2014 @ 16:43
    Harish
    0

    Hi 

    I am having umbraco 6.1.6 version, and insatalled ezsearch package.

    Can any one help me out,  to exclude folder names, .png, .jpg extensions etc from ezsearch result set.......

    i need to retrive content(pages) and some media type (like .doc, .pdf )  only.

    Now when I am searching I am getting pics, folder name, which I dont want to show it in ezsearch result.

    Thanks in advance.

Please Sign in or register to post replies

Write your reply to:

Draft