Copied to clipboard

Flag this post as spam?

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


  • Michael 63 posts 211 karma points
    Dec 16, 2013 @ 14:52
    Michael
    0

    public examine member search

    Hi folks

    I am working on a search function for a protected area of a website. It needs to search in the members section. I need to be able to search on the Name and two custom properties.

    I followed the videoes by Tim on umbraco

    In my ExamineIndex.config l added:

    <IndexSet SetName="MemberSearchIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/MemberSearch/">
        <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="afdeling" />
          <add Name="telefonnummer" />
        </IndexUserFields>
        <IncludeNodeTypes />
        <ExcludeNodeTypes />
      </IndexSet>

    And in the ExamineSettings.config I added:

    <ExamineIndexProviders>
        <providers>
          <add name="MemberSearchIndexer" type="UmbracoExamine.UmbracoMemberIndexer, UmbracoExamine" supportUnpublished="true" supportProtected="true" analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" indexSet="MemberSearchIndexSet" />
        </providers>
      </ExamineIndexProviders>
      <ExamineSearchProviders defaultProvider="ExternalSearcher">
        <providers>
          <add name="MemberSearchSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcards="true" indexSet="MemberSearchIndexSet" />
        </providers>
      </ExamineSearchProviders>

    The usercontrol and my search field are set up just like in the video.

    What am I doing wrong?

    Any help/pointers welcome :)

    Thanks in advance.

     

    /Michael

  • nojaf 91 posts 300 karma points
    Dec 16, 2013 @ 15:05
    nojaf
    0

    Are there any files in the ~/App_Data/TEMP/ExamineIndexes/MemberSearch/ folder?

  • Michael 63 posts 211 karma points
    Dec 16, 2013 @ 15:08
    Michael
    0

    Just these :)

  • nojaf 91 posts 300 karma points
    Dec 16, 2013 @ 16:27
    nojaf
    0

    Looks good, could you show us some code that does the searchquery (I haven't seen those videos)?

  • Michael 63 posts 211 karma points
    Dec 17, 2013 @ 08:25
    Michael
    0

    My ascx code looks like this:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="SearchResults.ascx.cs" Inherits="SearchResults" %>

    <asp:Repeater ID="SearchResultListing" runat="server">
      <HeaderTemplate>
        <ul>
      </HeaderTemplate>
      <ItemTemplate>
        <li>
          <%# ((Examine.SearchResult)Container.DataItem).Fields["nodeName"]%>
        </li>
      </ItemTemplate>
      <FooterTemplate>
        </ul>
      </FooterTemplate>
    </asp:Repeater>

    And the ascx.cs

    using Examine;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class SearchResults : System.Web.UI.UserControl
    {
      // The term being searched on
      protected string SearchTerm { get; private set; }

      // The search results list
      protected IEnumerable<SearchResult> SearchResults { get; private set; }
      public SearchResults()
      {
        SearchTerm = string.Empty;
        SearchResults = new List<SearchResult>();
      }
        protected void Page_Load(object sender, EventArgs e)
        {
          SearchTerm = Request.QueryString["s"];
          if (string.IsNullOrEmpty(SearchTerm)) return;

          var criteria = ExamineManager.Instance.SearchProviderCollection["MemberSearchSearcher"].CreateSearchCriteria();

          var filter = criteria.GroupedOr(new string[] { "nodeName", "afdeling", "telefonnummer" }, SearchTerm).Not().Field("umbracoNaviHide", "1").Compile();

          SearchResults = ExamineManager.Instance.SearchProviderCollection["MemberSearchSearcher"].Search(filter);

          SearchResultListing.DataSource = SearchResults;
          SearchResultListing.DataBind();
        }
    }

     

  • nojaf 91 posts 300 karma points
    Dec 17, 2013 @ 09:08
    nojaf
    0

    Hmm, looks ok. Did you try a ToLower() on your searchterm. I don't think Examine is case sensitive.

  • Michael 63 posts 211 karma points
    Dec 17, 2013 @ 13:49
    Michael
    0

    No luck with:

    SearchTerm = Request.QueryString["s"].ToLower();

     

    BTW, my search field code looks like this:

    <form action="/search" method="get">
      <input type="text" name="s" />
      <input type="submit" value="Search" />
    </form>
    

    I get this error on my searchresults page: Error loading userControl '~/usercontrols/SearchResults.ascx'

    Right now my ascx.cs and .ascx are both just copied to the umbraco usercontrols folder. Could that be causing the error? Does it need to be a dll instead?

Please Sign in or register to post replies

Write your reply to:

Draft