Copied to clipboard

Flag this post as spam?

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


  • TaoistTotty 246 posts 314 karma points
    Sep 01, 2010 @ 15:47
    TaoistTotty
    0

    Examine not giving UserFields in results

    I have tried to follow the video's about the examine function in Umbraco, and the search is working and giving results.

    The problem is that the results are only the built in fields and not the custom fields I have chosen.

    What am I doing wrong/where is a good place to look?

    Am happy to post any bits of code needed.

    Many thanks.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 01, 2010 @ 16:11
    Dirk De Grave
    0

    Have you added those user fields to the config file for indexing?

    <ExamineLuceneIndexSets>
      <!-- The internal index set used by Umbraco back-office - DO NOT REMOVE -->
      <IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/ExamineIndexes/Internal/">
        <IndexAttributeFields>
          <add Name="id" />
          <add Name="nodeName" />
          <add Name="updateDate" />
          <add Name="writerName" />
          <add Name="path" />
          <add Name="nodeTypeAlias" />
          <add Name="parentID" />
        </IndexAttributeFields>
        <IndexUserFields />
        <IncludeNodeTypes/>
        <ExcludeNodeTypes />
      </IndexSet>
    </ExamineLuceneIndexSets>

    Add your user fields under the IndexUserFields node. Or if you need to limit or exclude certain node types, use the corresponding node in the config.

     

    Hope this helps.

    Regards,

    /Dirk

     

     

     

  • TaoistTotty 246 posts 314 karma points
    Sep 01, 2010 @ 16:36
    TaoistTotty
    0

    Dirk, thank you for your reply.

    I have done this, the files I am using are:

    ExamineIndex.config

    <ExamineLuceneIndexSets>
    <!-- The internal index set used by Umbraco back-office - DO NOT REMOVE -->
    <IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/ExamineIndexes/Internal/">
    <IndexAttributeFields>
    <add Name="id" />
    <add Name="nodeName" />
    <add Name="updateDate" />
    <add Name="writerName" />
    <add Name="path" />
    <add Name="nodeTypeAlias" />
    <add Name="parentID" />
    </IndexAttributeFields>
    <IndexUserFields />
    <IncludeNodeTypes/>
    <ExcludeNodeTypes />
    </IndexSet>
    <IndexSet SetName="StoreIndexSet" IndexPath="~/App_Data/ExamineIndexes/Store3/">
    <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="productName" />
    <add Name="produdtDescription" />
    <IncludeNodeTypes />
    <ExcludeNodeTypes />
    </IndexSet>
    </ExamineLuceneIndexSets>

    ExamineSettings.config

    <Examine>
    <ExamineIndexProviders>
    <providers>
    <add name="InternalIndexer" type="UmbracoExamine.LuceneExamineIndexer, UmbracoExamine"
    runAsync="true"
    supportUnpublished="true"
    supportProtected="true"
    interval="10"
    analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>
    <add name="StoreIndexer" type="UmbracoExamine.LuceneExamineIndexer, UmbracoExamine"
    runAsync="true"
    supportUnpublished="false"
    supportProtected="false"
    interval="10"
    analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"
    indexSet="StoreIndexSet"/>
    </providers>
    </ExamineIndexProviders>
    <ExamineSearchProviders defaultProvider="InternalSearcher">
    <providers>
    <add name="InternalSearcher" type="UmbracoExamine.LuceneExamineSearcher, UmbracoExamine"
    analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>
    <add name="StoreSearcher" type="UmbracoExamine.LuceneExamineSearcher, UmbracoExamine"
    analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"
    indexSet="StoreIndexSet"/>
    </providers>
    </ExamineSearchProviders>
    </Examine>

    ASCX

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DemoSearchResults.ascx.cs" Inherits="ExamineTest.usercontrols.DemoSearchResults" %>
    <%@ Import Namespace="ExamineTest.usercontrols" %>

    <p>
    Your search for :&nbsp;<b><u><%=SearchTerm%></u></b>&nbsp;returned&nbsp;
    <i><b><%=this.SearchResults.Count()%></b>&nbsp; result(s)</i>
    </p>


    <asp:Repeater ID="SearchResultListing" runat="server" >
    <HeaderTemplate>
    <ul>
    </HeaderTemplate>
    <ItemTemplate>
    <li>
    <a href='<%#((Examine.SearchResult)Container.DataItem).FullUrl()%>' target="_blank">
    <span class="title">
    <%# ((Examine.SearchResult)Container.DataItem).Fields["nodeName"]%>
    </span>
    </a>
    </li>
    </ItemTemplate>
    <FooterTemplate>
    </ul>
    </FooterTemplate>
    </asp:Repeater>

    And finally code behind.

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

    namespace ExamineTest.usercontrols
    {
    public static class SearchResultExtensions
    {
    public static string FullUrl(this SearchResult sr)
    {
    return umbraco.library.NiceUrl(sr.Id);
    }

    }

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

    /// <summary>
    /// The search results list
    /// </summary>
    protected IEnumerable<SearchResult> SearchResults { get; private set; }

    public DemoSearchResults()
    {
    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["StoreSearcher"]
    .CreateSearchCriteria(UmbracoExamine.IndexTypes.Content);

    var filter = criteria
    .GroupedOr(new string[] { "nodeName", "productName", "productDescription" }, SearchTerm)
    .Compile();

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

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

    }
    }
    }

    I am using Umbraco 4.5.1.

     

    I hope this helps.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 01, 2010 @ 16:43
    Dirk De Grave
    1

    Sounds ok to me (from looking at the config settings), have you checked whether the fields get into the indexes? Can use Luke to open up the index files and check whether the fields can actually be found in the index

     

    Let's know what you find!

     

    Cheers,

    /Dirk

  • TaoistTotty 246 posts 314 karma points
    Sep 01, 2010 @ 17:26
    TaoistTotty
    0

    Dirk

    Thank you for your reply, it has taken a while to get Java installed on the server.

    They are in the index.

    I assume this means the ascx is wrong somewhere along the line?

    Thanks

    TT

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 01, 2010 @ 17:36
    Ismail Mayat
    0

    on ur search results page write out the generated query ( filter.ToString() in your case should give you the generated query) then try that query in luke try changing the analyser in luke to see if you get results for that query. Are you usng rc3 of examine?

    Regards

    Ismail

  • TaoistTotty 246 posts 314 karma points
    Sep 01, 2010 @ 17:38
    TaoistTotty
    0

    Ismail

    Thank you for your suggestion, I will give it a go.

    I am using the version of Examine that came with Umbraco 4.5.1

    Regards

    TT

  • TaoistTotty 246 posts 314 karma points
    Sep 01, 2010 @ 18:07
    TaoistTotty
    0

    Ismail

    Have tried the following, and am seeing this error:

    Cannot parse '{SearchIndexType: Content, LuceneQuery: +(+(nodeName:Steak productName:Steak productDescription:Steak)) +__IndexType:content } ': Encountered " <RANGEEX_GOOP> "LuceneQuery: "" at line 1, column 27.
    Was expecting:
    "}" ...

    Does this help?

    Regards

    TT

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 02, 2010 @ 09:59
    Ismail Mayat
    0

    When say tried the following do you mean you pasted the following query into luke?

    {SearchIndexType: Content, LuceneQuery: +(+(nodeName:Steak productName:Steak productDescription:Steak)) +__IndexType:content } 

    If so the that is not correct what you need to paste is 

    +(+(nodeName:Steak productName:Steak productDescription:Steak)) +__IndexType:content

     

    Or is the output what you actually get when you do .ToString() on criteria object? If its the latter then you may need to put on codeplex as issue with your code as it may be a bug.

    Regards

    Ismail

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 02, 2010 @ 10:14
    Aaron Powell
    1

    If you disable async on the indexer it will be able to write to the Umbraco log table if/ when errors occur during indexing. Try this as it may give a bit of an insight into any problems that are causing the fields not to be indexed.

    Additionally, the fields are case-sensitive, so ensure that your field names what you've got in the config match the alias in Umbraco.

  • TaoistTotty 246 posts 314 karma points
    Sep 02, 2010 @ 10:32
    TaoistTotty
    0

    Ismail

    Thank you for your reply.

    The top one, is what the .ToString() is producing, and I copied into Luke.

    Have now tried the lower option and got a result in Luke.

     

    slace, I will give this a go.

     

    I will upgrade to 4.5.2 in a couple of minutes just to see if this helps.

    Many thanks

    TT

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 02, 2010 @ 10:44
    Ismail Mayat
    1

    TT,

    Looking at your config for store set index you have

    Lucene.Net.Analysis.WhitespaceAnalyzer

    Try using that analyser in luke and i reckon you will not get any results for same query. So for your store set indexer and searcher take out that analyser so you then have

     <add name="StoreSearcher" type="UmbracoExamine.LuceneExamineSearcher, UmbracoExamine"
               

                             
    indexSet="StoreIndexSet"/>

    Then rebuild your storeset index, when you dont specify analyser it defaults to standard, then try search you should then get results.

    Regards

    Isamil

  • TaoistTotty 246 posts 314 karma points
    Sep 02, 2010 @ 10:49
    TaoistTotty
    0

    Ismail

    Thanks for the suggestion, will give it a go.

    Regards

    TT

  • TaoistTotty 246 posts 314 karma points
    Sep 02, 2010 @ 11:00
    TaoistTotty
    0

    Ismail

    Many thanks, that did the trick.

    It is working now and giving results.

    Thanks once again.

    TT

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 02, 2010 @ 11:08
    Ismail Mayat
    1

    TT,

    It caught be out as well, but having done some lucene before knew a little about the analyzers.  Two things are absolute must when working with lucene, Luke and the lucene in action book will save a lot time and effort.

    Regards

    Ismail

  • TaoistTotty 246 posts 314 karma points
    Sep 02, 2010 @ 11:25
    TaoistTotty
    0

    Ismail

    Thanks for this, I have just ordered the book.

    Thanks once again.

    Regards

    TT

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 02, 2010 @ 13:06
    Aaron Powell
    0

    I've done a bit of an overview of analyzers on my website: http://www.aaron-powell.com/lucene-analyzer

    That'll keep you appeased until the book arrives ;)

  • TaoistTotty 246 posts 314 karma points
    Sep 02, 2010 @ 13:27
    TaoistTotty
    0

    Many thanks slace.

    I will have a look at this.

    Regards

    TT

Please Sign in or register to post replies

Write your reply to:

Draft