Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jul 19, 2012 @ 12:59
    Ismail Mayat
    0

    Boosting examine fields during indexing

    Guys,

    Does anyone know how to boost fields during indexing?  There is GatheringNodeData method but there is nothing exposed at that point to boost fields. Looking at lucene documentation boosting needs lucene apis and looks like examine which is wrapper around Lucene does not expose the guts of Lucene.

    Any ideas on how todo this?

    Regards

    Ismail 

  • jaygreasley 416 posts 403 karma points
    Jul 19, 2012 @ 13:44
    jaygreasley
    0

    Not sure if you can do it an indexing time but you may be able to do it at search time. You'll have the lucene assembly in Umbraco so canjust reference it and create a term query thus:

    using Lucene.Net.Index;

    using Lucene.Net.Search;

                Term t = new Term("test");

                TermQuery tq = new TermQuery(t);

                tq.SetBoost(10);

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jul 19, 2012 @ 13:47
    Ismail Mayat
    0

    Jay,

    The fluent examine api already gives you boosting at query time, however no good for my situation. Basically have search which has mix of doc types. One type of doc is person and person has title. Depending on title i want to boost that field so if senior type person they need to appear higher up the returned result set.

    Regards

    Ismail 

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jul 19, 2012 @ 14:21
    Ismail Mayat
    0

    Jay,

    Just found this old post http://our.umbraco.org/forum/developers/extending-umbraco/16269-Examine-Field-Document-Boost however I don't think the document writing event is available anymore?

    Regards

    Isamil

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jul 19, 2012 @ 14:37
    Ismail Mayat
    0

    Jay,

    Figured it out not tested the code but 

    ar indexer = (UmbracoContentIndexer)ExamineManager.Instance.IndexProviderCollection[Constants.ATGMDirectoryIndexerName];

                indexer.DocumentWriting += indexer_DocumentWriting;

     

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

            {

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

                field.SetBoost(0.9f);

            }

     

    "should" in theory work! 

  • jaygreasley 416 posts 403 karma points
    Jul 19, 2012 @ 15:17
    jaygreasley
    0

    nice find. that should do it (you also have e.Document.SetBoost  if required)

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jul 19, 2012 @ 15:24
    Ismail Mayat
    0

    yup e.Document.SetBoost(1f)

    etc etc

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jul 19, 2012 @ 15:56
    Ismail Mayat
    0

    Jay,

    That definately works. Just boosted a field woohoo!!

    Regards

    Ismail

  • jaygreasley 416 posts 403 karma points
    Jul 19, 2012 @ 20:19
    jaygreasley
    0

    nice, good work matey :-)

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Oct 29, 2012 @ 16:58
    Tim
    0

    Hi Ismail, trying to do something like this to boost documents, but I'm getting the error: The type 'Lucene.Net.Documents.Document' is defined in an assembly that is not referenced. You must add a reference to assembly 'Lucene.Net, Version=2.9.4.1, Culture=neutral, PublicKeyToken=85089178b9ac3181'.

    I am referencing the Lucene.Net DLL (the one that ships with Umbraco 4.8), which I thought was this one....... any ideas?

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Oct 29, 2012 @ 17:05
    Ismail Mayat
    0

    Tim,

    Does this need the uComponents compatiblity hack? The other older lucene version in bin/legacy folder? Or try and get the latest version of examine from codeplex and see what version of lucene that is using?  Basically the document class is being exposed via examine so whatever version Examine is using that is the version you will need.

    Regards

    Ismail

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Oct 29, 2012 @ 17:51
    Tim
    0

    Fixed it, schoolboy error (added the reference to the wrong project)! On an unrelated note, have you done much with indexing stuff that doesn't come from Umbraco? I've got a project where we use a SimpleDataService to index from a web service, but it doesn't appear to fire the DocumentWriting event for some reason....... ever come across that?

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Oct 30, 2012 @ 12:52
    Ismail Mayat
    0

    Tim,

    Never used document writing event with custom indexer. I have got custom indexer that indexes a db and I have used gatheringnode data event.  Have you had a look at codeplex issue tracker see if anyone else has had same issue with document writing on simpledataservice?

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft