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.
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:
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.
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?
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.
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?
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?
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
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);
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
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
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!
nice find. that should do it (you also have e.Document.SetBoost if required)
yup e.Document.SetBoost(1f)
etc etc
Jay,
That definately works. Just boosted a field woohoo!!
Regards
Ismail
nice, good work matey :-)
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?
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
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?
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
is working on a reply...