Using Examine to index search with ANY data source
Now that Examine is part of Umbraco, I figure I might be able to get help here since documentation is pretty scare anywhere else.
I am trying to set this up for the current version (FarmCode docs are for old version) and trying to use a SQL database (sample uses XML file). I seems to be working, sort of. I can get the index to create but not populate.
My ExamineIndex.config (abreviated):
<?xmlversion="1.0"?><ExamineLuceneIndexSets> <!-- The custom data index set --> <IndexSetSetName="MemberFinderIndexSet"IndexPath="~/App_Data/ExamineIndexes/MemberFinder/"> <IndexUserFields> <addName="name_first" /> <addName="name_middle" /> <addName="name_last" /> </IndexUserFields> </IndexSet></ExamineLuceneIndexSets>
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using Examine;
using Examine.LuceneEngine;
namespace SBA.AZBar.UserControls
{
///<summary>/// The data service used by the LuceneEngine in order for it to reindex all data///</summary>publicclassMemberFinderDataService : Examine.LuceneEngine.ISimpleDataService
{
///<summary>/// loads the data source into memory///</summary>static MemberFinderDataService()
{
SqlCommand cmd = newSqlCommand();
StringBuilder sql = newStringBuilder();
sql.Append("SELECT * FROM Populate_Search");
cmd.CommandText = sql.ToString();
SqlConnection con = newSqlConnection(ConfigurationManager.ConnectionStrings["Membership"].ToString());
cmd.Connection = con;
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
DataTable dt = newDataTable();
dt.Load(reader);
con.Close();
}
privatestaticDataTable dt;
///<summary>/// Returns a list of type SimpleDataSet based on the Populate_Search view query///</summary>///<param name=indexType"></param>/// <returns></returns>publicIEnumerable<SimpleDataSet> GetAllData(string indexType)
{
var data = newList<SimpleDataSet>();
//open the datatable and iterate the rowsforeach (DataRow row in dt.Rows)
{
// add a new SimpleDataSet object to the list
data.Add(newSimpleDataSet()
{
// create the node definition, ensure that it is the same type as referenced in the config
NodeDefinition = newIndexedNode()
{
NodeId = (int)row["id"],
Type = "CustomData"
},
// add the data to the row
RowData = newDictionary<string, string>()
{
{"id", (string)row["id"]},
{"name_first", (string)row["name_first"]},
{"name_middle", (string)row["name_middle"]},
{"name_last", (string)row["name_last"]}
}
});
}
return data;
}
}
}
Using Examine to index search with ANY data source
Now that Examine is part of Umbraco, I figure I might be able to get help here since documentation is pretty scare anywhere else.
I am trying to set this up for the current version (FarmCode docs are for old version) and trying to use a SQL database (sample uses XML file). I seems to be working, sort of. I can get the index to create but not populate.
My ExamineIndex.config (abreviated):
My ExamineSettings.config (abbreviated):
and My MemberFinderDataService.cs:
Bump! Anyone?
Is this working??
is working on a reply...