Copied to clipboard

Flag this post as spam?

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


  • Peter Duncanson 430 posts 1360 karma points c-trib
    Aug 06, 2012 @ 18:47
    Peter Duncanson
    0

    Examine, can you change weightings of doctypes?

    Had a legit request from a client that they want the parent nodes to come higher up the rankings than any children which might contain the same searched for phrase/word. So give this tree:

    Cars
    - Ford
    - VW
    - Lada

    if searching for "engine" (which lets say all pages contain) they want to have the "Cars" node listed first. Note this "weighting" might not be based on the tree position so we thought if we could adjust the weighting per doctype (in this example "Cars" is a different doctype than the child manufactures)?

    Cheers

    Pete

  • jaygreasley 416 posts 403 karma points
    Aug 06, 2012 @ 20:42
  • jaygreasley 416 posts 403 karma points
    Aug 06, 2012 @ 22:29
    jaygreasley
    1

    a little snippet (doesn;t do it based on doctype, but may help):

    this has the boost value for the document on a doc property. (untested but gives you an idea).

    I'm not sure you can get the doctype (or any node data for that matter) at Document Writing time but am quite possibly wrong :-)

    var indexer = (UmbracoContentIndexer)ExamineManager.Instance.IndexProviderCollection["indexname"];

            

                indexer.DocumentWriting += indexer_DocumentWriting;

            }

     

            void indexer_DocumentWriting(object sender, Examine.LuceneEngine.DocumentWritingEventArgs e)

     

            {

     

                var field= e.Document.GetField("BoostScore");

     

                e.Document.SetBoost(float.Parse(field.ToString()));

            }

Please Sign in or register to post replies

Write your reply to:

Draft