An adapter used to provide a predefined DataSet to DocumentImporter and DocumentIndex.
| C# | C# | Visual Basic | Visual Basic | Visual C++ | Visual C++ | F# | F# |
public class PresetDataSetAdapter : IDataSetAdapter
public class PresetDataSetAdapter : IDataSetAdapter
Public Class PresetDataSetAdapter Implements IDataSetAdapter
Public Class PresetDataSetAdapter Implements IDataSetAdapter
public ref class PresetDataSetAdapter : IDataSetAdapter
public ref class PresetDataSetAdapter : IDataSetAdapter
type PresetDataSetAdapter = class interface IDataSetAdapter end
type PresetDataSetAdapter = class interface IDataSetAdapter end
| All Members | Constructors | Methods | Properties | ||
| Icon | Member | Description |
|---|---|---|
| PresetDataSetAdapter(DataSet) |
New instance
| |
| Equals(Object) | (Inherited from Object.) | |
| Finalize()()()() | (Inherited from Object.) | |
| GetDataSet(Int32, Int32) |
Retreives the next page of data
| |
| GetHashCode()()()() | (Inherited from Object.) | |
| GetType()()()() | (Inherited from Object.) | |
| Location |
Unused
| |
| MemberwiseClone()()()() | (Inherited from Object.) | |
| Query |
Unused
| |
| ToString()()()() | (Inherited from Object.) |
Note: Only the data in Tables[0] (the first table in the set) is indexed.
In this example a DataSet is created, indexed and then searched. The fictional r.aspx could be created to present
relevant information to the user, such as the 'body' field.
DataSet CreateTestData()
{
DataSet ds = new DataSet();
DataTable tab =new DataTable("testTable");
ds.Tables.Add(tab);
//The first column in the set is used as the result title
tab.Columns.Add("title");
tab.Columns.Add("oid");
tab.Columns.Add("body");
tab.Rows.Add(new object[]{"object1", 1, "this is the body for object1"});
tab.Rows.Add(new object[]{"object2", 2, "something about this object - its #2"});
tab.Rows.Add(new object[]{"object3", 3, "more stuff and this is number 3, has this more than once"});
tab.Rows.Add(new object[]{"object4", 4, "object4 has something else"});
return ds;
}
public void IndexDataSet()
{
//Specify where to store the index
Configuration configuration = new Configuration();
configuration.IndexDirectory = "c:/IndexDirectory";
//Create an indexable source record, defining:
IndexableSourceRecord indexableSourceRecord = new IndexableSourceRecord(
SourceType.PresetDataSetProvider, //this is a preset DataSet
null, //not applicable
null, //not applicable
"oid", //the 'primary key'/'identifying' field name
"http://localhost/r.aspx?key={0}&keyField={1}" //the format to use for the result URLs
);
//Assign any number not currently assigned to an existing source
indexableSourceRecord.ID = 900001;
//Create the adapter around any DataSet
PresetDataSetAdapter presetDataSetAdapter = new PresetDataSetAdapter(CreateTestData());
//Create the IndexableSource around the adapter
DataSetBasedSource dataSetBasedSource = new DataSetBasedSource(configuration, indexableSourceRecord, presetDataSetAdapter);
//Create the importer
DocumentIndex documentIndex = new DocumentIndex(configuration);
documentIndex.RegisterDataSetBasedSource(indexableSourceRecord.ID, dataSetBasedSource);
//Import from the IndexableSource
documentIndex.Import( indexableSourceRecord, dataSetBasedSource );
documentIndex.Close();
//Run a test search
string searchQuery = "this";
SearchAgent searchAgent = new SearchAgent(searchQuery, licKey, configuration);
//Register the IndexableSource for URL mapping
searchAgent.RegisterDataSetBasedSource(indexableSourceRecord.ID, dataSetBasedSource);
SearchResult result = searchAgent.Search(1, 10);
//Expected results
System.Diagnostics.Debug.Assert(3 == result.Count);
System.Diagnostics.Debug.Assert("http://localhost/r.aspx?key=3&keyField=oid" == (result[0] as ResultItem).UriString);
System.Diagnostics.Debug.Assert("object3" == (result[0] as ResultItem).Title);
}
| Object | |
| PresetDataSetAdapter | |
Assembly: Keyoti4.SearchEngine.Core (Module: Keyoti4.SearchEngine.Core.dll) Version: 2015.6.15.120