Inserting Data into Real-Time Indexes
With the release of version 1.10.1 Sphinx introduced the real-time index type. With this type of index, records can be inserted via SphinxQL INSERT and REPLACE statements at any time without the need of running the indexer. Records can also be deleted via the SphinxQL DELETE statement.
Inserting Records via the SphinxQLCommand Class
The following example shows how to insert data an index called rt_index that has two columns called title and content:
C#
using (SphinxQLConnection sphinxQLConnection = new SphinxQLConnection(connectionString))
{
SphinxQLCommand sphinxQLCommand = sphinxQLConnection.CreateCommand("INSERT into rt_index (id, title, content) VALUES (@rtid, @title, @content)");
sphinxQLCommand.Parameters.Add("rtid", 1, SphinxType.UInt);
sphinxQLCommand.Parameters.Add("title", "My Title", SphinxType.String);
sphinxQLCommand.Parameters.Add("content", "My Content", SphinxType.String);
sphinxQLConnection.Open();
sphinxQLCommand.ExecuteNonQuery();
}