I'm looking to create a dynamic tag cloud for the website and was hoping to use the examine index. Does anyone know if this can be done and have any help in any way....
See http://richardfriedman.blogspot.com/2007/06/creating-tag-cloud.html however the links seem to be broken for source and its in php there is also java version but again broken links you might be able to contact the guy for source and port to .net. Think you will need to work directly with lucene and not examine.
You can then easily sort as Freq implements IComparable. So you give it the index and a field that you want to inspect good one would be bodyText. Works for me.
Tag cloud from examine....
I'm looking to create a dynamic tag cloud for the website and was hoping to use the examine index. Does anyone know if this can be done and have any help in any way....
Thanks
Craig,
See http://richardfriedman.blogspot.com/2007/06/creating-tag-cloud.html however the links seem to be broken for source and its in php there is also java version but again broken links you might be able to contact the guy for source and port to .net. Think you will need to work directly with lucene and not examine.
Regards
Ismail
Craig,
I have something working the method is
public List<Freq> GetTopTermsWithCount(string index,string fieldToSearch)
{
var listTerms = new List<Freq>();
string indexPath = GetIndexPath(index);
var reader = IndexReader.Open(indexPath);
TermEnum termEnum = reader.Terms();
while(termEnum.Next())
{
if(termEnum.Term().Field().Equals(fieldToSearch))
{
Freq freq = new Freq(termEnum.Term().Text(), termEnum.DocFreq());
listTerms.Add(freq);
}
}
listTerms.Sort();
reader.Close();
return listTerms;
}
private string GetIndexPath(string indexToQuery)
{
string configFile = HttpContext.Current.Server.MapPath("/config/ExamineIndex.Config");
// Create the query
var config =
XElement.Load(configFile).Elements("IndexSet").Where(
c => c.Attribute("SetName").Value == indexToQuery.Replace("Indexer", "IndexSet"));
return HttpContext.Current.Server.MapPath(config.Attributes("IndexPath").FirstOrDefault().Value +"Index");
}
and the Freq class
public class Freq:IComparable
{
#region IComparable Members
private string term;
private int frequency;
public string TermValue
{
get
{
return term;
}
}
public int FrequencyNo
{
get { return frequency; }
}
public Freq(string Term,int Frequeny)
{
term = Term;
frequency = Frequeny;
}
public int CompareTo(object obj)
{
Freq oFreq = (Freq) obj;
return frequency.CompareTo(oFreq.frequency);
}
#endregion
}
You can then easily sort as Freq implements IComparable. So you give it the index and a field that you want to inspect good one would be bodyText. Works for me.
Regards
Ismail
is working on a reply...