An adapter used to provide a predefined DataSet to DocumentImporter and DocumentIndex.
Declaration Syntax
C# | Visual Basic |
public class PresetDataSetAdapter : IDataSetAdapter
Public Class PresetDataSetAdapter Implements IDataSetAdapter
Members
All Members | Constructors | Methods | Properties | ||
Icon | Member | Description |
---|---|---|
PresetDataSetAdapter(DataSet) |
New instance
| |
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize()()()() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetDataSet(Int32, Int32) |
Retreives the next page of data
| |
GetHashCode()()()() | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType()()()() | Gets the type of the current instance. (Inherited from Object.) | |
Location |
Unused
| |
MemberwiseClone()()()() | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Query |
Unused
| |
ToString()()()() | Returns a string that represents the current object. (Inherited from Object.) |
Remarks
Note: Only the data in Tables[0] (the first table in the set) is indexed.
Examples
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); }
Inheritance Hierarchy
Object | |
PresetDataSetAdapter |
Assembly: Keyoti4.SearchEngine.Core (Module: Keyoti4.SearchEngine.Core.dll) Version: 2022.8.22.610