![]() | 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.
The following example shows how to insert data an index called rt_index that has two columns called title and content:
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(); }
![]() |
---|
It is recommended to use parameters, as shown above, to pass the values to insert to the SphinxQLCommand object. Using parameters will make sure that all values are being correctly escaped. |