An adapter used to provide a predefined DataSet to DocumentImporter and DocumentIndex.
Declaration Syntax
C# | Visual Basic | Visual C++ |
public class PresetDataSetAdapter : IDataSetAdapter
Public Class PresetDataSetAdapter _ Implements IDataSetAdapter
public ref class PresetDataSetAdapter : 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 attempt to free resources and perform other cleanup operations before the Object 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
DocumentImporter documentImporter = new DocumentImporter(configuration);
//Import from the IndexableSource
documentImporter.Open();
documentImporter.Import( indexableSourceRecord, dataSetBasedSource );
documentImporter.Close();
//Create the index builder
DocumentIndex documentIndex = new DocumentIndex(configuration);
//Register the IndexableSource for use by the 'row reader'
documentIndex.Open();
documentIndex.RegisterDataSetBasedSource(indexableSourceRecord.ID, dataSetBasedSource);
//Build the index
documentIndex.Build();
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 |