Copied to clipboard

Flag this post as spam?

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


  • Deepak 7 posts 88 karma points c-trib
    May 01, 2017 @ 22:41
    Deepak
    0

    Examine Search issues Umbraco v 7.5.12

    I am facing issue with Examine search using Lucene engine.

    I have an "ArticlePage" document type defined with following user index fields:

    1. activityTags (field type: Tag)
    2. locationTags (field type: Tag)
    3. contentTags (field type: Tag)
    4. articleTitle (field type: Textstring)
    5. articleSummary (field type: Rich Text Editor)
    6. articleBody (field type: Rich Text Editor)

    Here is the config details: ExamineIndex.config

      <IndexSet SetName="ArticlePageIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/ArticlePage">
        <!--the standard properties-->
        <IndexAttributeFields>
          <add Name="id" />
          <add Name="nodeName" />
          <add Name="updateDate" />
          <add Name="writerName" />
          <add Name="path" />
          <add Name="nodeTypeAlias" />
          <add Name="parentID" />
        </IndexAttributeFields>
        <!--the document type properties we created - use exact alias-->
        <IndexUserFields>
          <add Name="activityTags" />
          <add Name="locationTags" />
          <add Name="contentTags" />
          <add Name="articleTitle" />
          <add Name="articleSummary" />
          <add Name="articleBody" />
        </IndexUserFields>
        <!--confine to nodes of document type ArticlePage-->
        <IncludeNodeTypes>
          <add Name="ArticlePage"/>
        </IncludeNodeTypes>   </IndexSet>
    

    ExamineSettings.Config (other settings are present, but pasting the relevant setting configure for search):

      <ExamineIndexProviders>
        <providers>
          <add name="InternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine" supportUnpublished="true" supportProtected="true" analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net" />
          <add name="InternalMemberIndexer" type="UmbracoExamine.UmbracoMemberIndexer, UmbracoExamine" supportUnpublished="true" supportProtected="true" analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" />
          <!-- default external indexer, which excludes protected and unpublished pages-->
          <add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine" />
        <add name="ArticlePageIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine" supportProtected="true" analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
        </providers>
        </ExamineIndexProviders>
         <ExamineSearchProviders defaultProvider="ExternalSearcher">
            <providers>
              <add name="InternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net" />
              <add name="ExternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" />
              <add name="InternalMemberSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcard="true" />
    
              <!-- Searcher for Content Page -->
              <add name="ArticlePageSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
              <!--Searcher for Multiple Indexes-->
              <add name="MultiIndexSearcher" type="Examine.LuceneEngine.Providers.MultiIndexSearcher, Examine" 
                   indexSets="ArticlePageIndexSet" enableLeadingWildcards="true"/>
    
            </providers>
          </ExamineSearchProviders>
    

    The code for searching:

    //nodename being passed is AriticlePage Document Type Alias Name - "ArticlePage"
        var Searcher = ExamineManager.Instance.SearchProviderCollection["ArticlePageSearcher"];
              var searchCriteria = Searcher.CreateSearchCriteria();
              searchCriteria.Field("nodeTypeAlias", nodeName)
                              .And()
                              .Field("articleTitle", searchString.Escape())
                              .Or()
                              .Field("articleSummary", searchString.Escape())
                              .Or()
                              .Field("articleBody", searchString.Escape())
                              .Or()
                              .Field("activityTags", searchString.Escape())
                              .Or()
                              .Field("locationTags", searchString.Escape())
                              .Or()
                              .Field("contentTags", searchString.Escape())
                              .Or()
                              .Field("articleTitle", searchString.Fuzzy())
                              .Or()
                              .Field("articleSummary", searchString.Fuzzy())
                              .Or()
                              .Field("articleBody", searchString.Fuzzy())
                              .Or()
                              .Field("activityTags", searchString.Fuzzy())
                              .Or()
                              .Field("locationTags", searchString.Fuzzy())
                              .Or()
                              .Field("contentTags", searchString.Fuzzy());
    
              var searchResults = Searcher.Search(searchCriteria).OrderByDescending(x => x.Score);
    

    When I wire up the pages, call the search with the key word skiing, one result is shown in the search results which is as expected. The keyword skiing is present in artileTitle, articleSummary, articleBody of an article.

    When I search for another keyword avalanche which is present in the same article but only present in the articleBody. No results is found. I thought that's very strange.

    I open the Examine Dashboard in Umbraco, went to the ArticlePageSearcher clicked and open the search text box, searched for keywords skiing, yes correct result found, then searched for avalanche yes the correct result was found (same article as skiing)

    So why is the code searching for skiing keyword correctly and bring up the correct results and not doing the same for avalanche?

    Can someone please explain / help what I am doing wrong with the search using Examine in C# code given above??

    Please ask if you need further clarification

  • Deepak 7 posts 88 karma points c-trib
    May 04, 2017 @ 20:13
    Deepak
    0

    Can I get some answers from fellow Umbraco developers about this topic? Is the issue mentioned clear enough to investigate?

  • Marc Goodson 909 posts 5879 karma points MVP 4x c-trib
    May 09, 2017 @ 09:46
    Marc Goodson
    0

    Hi Deepak

    Hmm, it's hard for me to spot the problem here.

    The evidence points to an error with the searchcriteria generated via code(but you knew that!)

    You don't appear to be calling .Compile() anywhere?

    eg

    var searchCriteria = Searcher.CreateSearchCriteria();
    var query = searchCriteria.Field("nodeName","hello").Or().Field("metaTitle","hello").Compile();
    var searchResults = Searcher.Search(query);
    

    so I would try compiling the search criteria first, then seeing what the raw lucene syntax is being generated by the criteria, then use the lucene syntax in the back office search, enabling you to either immediately see what the issue is from the syntax / allow you to tweak the syntax to see what does work, then work back to update your c# fluent examine criteria to generate that syntax (or just use the raw lucene query to generate the searchcriteria)

    if that helps

    regards

    Marc

  • Deepak 7 posts 88 karma points c-trib
    May 10, 2017 @ 00:44
    Deepak
    0

    Hi Marc,

    Thanks for replying to my query.

    I have tried your suggestions.

    Adding ".compile()" at the end of searchCrieria as suggested by you. It made no difference.

    It can search the keyword "skiing" and bring up the results correctly.

    When I search for "avalanche", it brings up no results.

    I did check the processed query in Luke.Net (Lucene Index checking tool). The query runs properly. It brings up results for keyword skiing but not for avalanche. I don't know how to fine tune / tweak to get results for avalanche.

    Here is the processed query for keyword "skiing":

    +nodeTypeAlias:articlepage +articleTitle:skiing 
    articleSummary:skiing articleBody:skiing activityTags:skiing 
    locationTags:skiing contentTags:skiing articleTitle:skiing~0.5 
    articleSummary:skiing~0.5 articleBody:skiing~0.5 activityTags:skiing~0.5 
    locationTags:skiing~0.5 contentTags:skiing~0.5
    

    Here is the processed query for keyword "avalanche":

    +nodeTypeAlias:articlepage +articleTitle:avalanche 
    articleSummary:avalanche articleBody:avalanche activityTags:avalanche 
    locationTags:avalanche contentTags:avalanche articleTitle:avalanche~0.5 
    articleSummary:avalanche~0.5 articleBody:avalanche~0.5 
    activityTags:avalanche~0.5 locationTags:avalanche~0.5 
    contentTags:avalanche~0.5
    

    In the Umbraco backoffice (Examine Dashboard). The "ArticleSearcher" brings up the results correctly for "avalanche" keyword.

    So I am perplexed as to why the query (as mentioned above) can work in one situation (when keyword is skiing) and not for the other (when keyword is avalanche).

    Do you suggest any fine tuning tips that I should try for tweaking the processed query in Luke.Net or even for the code changes?

  • Marc Goodson 909 posts 5879 karma points MVP 4x c-trib
    May 10, 2017 @ 06:18
    Marc Goodson
    100

    Hi Deepak

    In the raw lucene syntax you have posted your search criteria produces

    +articleTitle:avalanche
    

    The + in lucene syntax means the term MUST appear in that field:

    https://lucene.apache.org/core/294/queryparsersyntax.html#+

    and from your explanation of the scenario, the avalanche word does not appear in the title of the page, only in the articleBody, hence it is not being returned for this search.

    I believe It is the And() in your searchcriteria that is adding the +

    but confirm this by searching in backoffice using lucene syntax option for:

    +nodeTypeAlias:articlepage articleTitle:avalanche articleSummary:avalanche articleBody:avalanche activityTags:avalanche locationTags:avalanche contentTags:avalanche articleTitle:avalanche~0.5 articleSummary:avalanche~0.5 articleBody:avalanche~0.5 activityTags:avalanche~0.5 locationTags:avalanche~0.5 contentTags:avalanche~0.5

    without the + and check you get the article...

    regrds

    Marc

  • Deepak 7 posts 88 karma points c-trib
    May 10, 2017 @ 13:00
    Deepak
    0

    Marc,

    Yes And() was the issue. Resolving And() into Or() worked and brought up three references to the article in the results.

    Can you please repost the link to https://lucene.apache.org/core/294/queryparsersyntax.html#+ ? It would help to check the syntax before I post it as an issue.

    Thanks for your help.

    regards,

    Deepak

  • Marc Goodson 909 posts 5879 karma points MVP 4x c-trib
    May 10, 2017 @ 16:05
    Marc Goodson
    0

    Great!

    Here is the link:

    https://lucene.apache.org/core/294/queryparsersyntax.html

    regards

    Marc

  • Deepak 7 posts 88 karma points c-trib
    May 10, 2017 @ 20:08
    Deepak
    0

    Marc,

    I think the search is now bringing the results that doesn't contain the keyword searched for. In other words, that its not correctly searching through the articles at all.

    I am not sure that changing And() to Or() worked really well.

    I even tried removing .Fuzzy() logic, it doesn't matter, just brings too many irrelevant search results.

    Can you please help? Thanks,

    Deepak

  • Marc Goodson 909 posts 5879 karma points MVP 4x c-trib
    May 13, 2017 @ 09:28
    Marc Goodson
    0

    Hi Deepak

    So hopefully you are now getting to grip with the lucene syntax and how the search works, if you have + next to a field it means it much contain the term, you are now getting matches on nodeTypeAlias, being an articlePage and therefore returning all results!

    I think you want to explore the GroupedOr and GroupedAnd helpers in examine

    https://umbraco.com/blog/examining-examine/

    basically you want to search multiple fields for a single term.

    eg

    var searchTerm = "avalaunche";
         var query = searchCriteria.Field("nodeTypeAlias", nodeName).And().GroupedOr(new string[] { "articleTitle", "articleSummary","articleBody","activityTags","locationTags","contentTags"}, searchTerm ).Compile(); 
    

    and check the Lucene syntax this generates...

    ... but if you want to boost the result if the term appears in articleTitle or locationTags you might have to split this out... eg

    var searchTerm = "avalaunche";
         var query = searchCriteria.Field("nodeTypeAlias", nodeName).And().GroupedOr(new string[] { "articleTitle", "locationTags"}, searchTerm.Boost(10)).Or().GroupedOr(new string[] {"articleSummary","articleBody","activityTags","locationTags","contentTags"}, searchTerm.Boost(2)).Compile(); 
    

    generally with this kind of search to refine it, I would be constantly checking the results of 20 to 30 key search terms, playing with the Lucene syntax that the examine query generates, and adjusting accordingly, but hard to advise without the data in front of me!

    hope that gets closer to you finding your avalanche!

  • Deepak 7 posts 88 karma points c-trib
    May 17, 2017 @ 15:41
    Deepak
    0

    Hi Marc,

    Thanks so much for coming back and providing some further pointers on how to change the search for better results.

    I will try out your suggestions and come back to you if I am still stuck.

    Thanks.

    Deepak

  • Bobi 235 posts 637 karma points
    May 17, 2017 @ 18:58
    Bobi
    0

    Perhaps someone can assist me with examine. I have the following node structure: a HomePage node and under that node I have various pages, including the articulate node.

    When I search the site for search terms located on the various pages, the search works great, and returns the results. However, when I try searching for items in the articulate blog nothing shows up.

    I am using the ezSearch plugin, which uses examine.

Please Sign in or register to post replies

Write your reply to:

Draft