<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Sphinx Search C# .NET Client&#160;API</title>
	<atom:link href="http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/feed/" rel="self" type="application/rss+xml" />
	<link>http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/</link>
	<description>Hi there. I&#039;m Christopher Gooley. I build technology. I like to share technology musings and products on this blog. I also like to ramble about non-technology topics. Besides coding, this is my main outlet for sharing and creativity.</description>
	<lastBuildDate>Mon, 06 Feb 2012 18:54:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Simon</title>
		<link>http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/comment-page-1/#comment-2910</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Thu, 05 Jan 2012 20:40:42 +0000</pubDate>
		<guid isPermaLink="false">http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/#comment-2910</guid>
		<description>Thanks for this project - I can&#039;t seem to get it to work though. I&#039;m using vb.net and have translated your sample code from this page into vb.net. And get a &quot;Object reference not set to an instance of an object&quot; error when trying to do anything with the results array.

Maybe I&#039;m not connecting to the host correctly (I&#039;m using the name my PC and port 3312 with searchd listening on that same port). I&#039;ve also tried with my local IP address. I would have thought if my connection was wrong it&#039;d error earlier on in the code but it doesn&#039;t even if I deliberately but an incorrect host and port.

Any pointers would be great - thanks.</description>
		<content:encoded><![CDATA[<p>Thanks for this project &#8211; I can&#8217;t seem to get it to work though. I&#8217;m using vb.net and have translated your sample code from this page into vb.net. And get a &#8220;Object reference not set to an instance of an object&#8221; error when trying to do anything with the results array.</p>
<p>Maybe I&#8217;m not connecting to the host correctly (I&#8217;m using the name my PC and port 3312 with searchd listening on that same port). I&#8217;ve also tried with my local IP address. I would have thought if my connection was wrong it&#8217;d error earlier on in the code but it doesn&#8217;t even if I deliberately but an incorrect host and port.</p>
<p>Any pointers would be great &#8211; thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: armando</title>
		<link>http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/comment-page-1/#comment-2822</link>
		<dc:creator>armando</dc:creator>
		<pubDate>Thu, 28 Apr 2011 22:34:20 +0000</pubDate>
		<guid isPermaLink="false">http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/#comment-2822</guid>
		<description>Hi,

Thanks for this library, I wonder if it allows real time index, I want to use that new feature, available since sphinx 1.10.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thanks for this library, I wonder if it allows real time index, I want to use that new feature, available since sphinx 1.10.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tralamazza</title>
		<link>http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/comment-page-1/#comment-2761</link>
		<dc:creator>Tralamazza</dc:creator>
		<pubDate>Tue, 16 Nov 2010 20:47:09 +0000</pubDate>
		<guid isPermaLink="false">http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/#comment-2761</guid>
		<description>Hi and thanks for this project, I wrote a simple sphinx client myself a while ago. I made it available here: dotsphinxclient.codeplex.com</description>
		<content:encoded><![CDATA[<p>Hi and thanks for this project, I wrote a simple sphinx client myself a while ago. I made it available here: dotsphinxclient.codeplex.com</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kendall</title>
		<link>http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/comment-page-1/#comment-2759</link>
		<dc:creator>kendall</dc:creator>
		<pubDate>Mon, 15 Nov 2010 05:37:58 +0000</pubDate>
		<guid isPermaLink="false">http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/#comment-2759</guid>
		<description>I am attempting to use you api with VB.net however I am having just a bit of trouble. In your example I do not see where you import the 
SphinxSearchApi.dll. Could you please shed a little light on this for me.</description>
		<content:encoded><![CDATA[<p>I am attempting to use you api with VB.net however I am having just a bit of trouble. In your example I do not see where you import the<br />
SphinxSearchApi.dll. Could you please shed a little light on this for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christopher Gooley</title>
		<link>http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/comment-page-1/#comment-2758</link>
		<dc:creator>Christopher Gooley</dc:creator>
		<pubDate>Sat, 13 Nov 2010 02:05:01 +0000</pubDate>
		<guid isPermaLink="false">http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/#comment-2758</guid>
		<description>I haven&#039;t made any changes at all since this release and I&#039;ve been using it in production on multiple (large) sites for over 2 years now.  Works great for me without any stability or other issues. 

Adding to the index is done through the sphinx indexer, not this client api.  The indexer can be configured to query your database incrementally to keep your index up to date. I have it doing index updates every 15 minutes, which is plenty fast for my users needs.</description>
		<content:encoded><![CDATA[<p>I haven&#8217;t made any changes at all since this release and I&#8217;ve been using it in production on multiple (large) sites for over 2 years now.  Works great for me without any stability or other issues. </p>
<p>Adding to the index is done through the sphinx indexer, not this client api.  The indexer can be configured to query your database incrementally to keep your index up to date. I have it doing index updates every 15 minutes, which is plenty fast for my users needs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/comment-page-1/#comment-2753</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Thu, 04 Nov 2010 21:38:44 +0000</pubDate>
		<guid isPermaLink="false">http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/#comment-2753</guid>
		<description>Hi there - have you published any updates to your code since this post?  I&#039;m wondering how stable you found this release.  I&#039;m going to check it out.

Question - does your API include methods to add text to the index or do I do that separately?

Thanks...</description>
		<content:encoded><![CDATA[<p>Hi there &#8211; have you published any updates to your code since this post?  I&#8217;m wondering how stable you found this release.  I&#8217;m going to check it out.</p>
<p>Question &#8211; does your API include methods to add text to the index or do I do that separately?</p>
<p>Thanks&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rusted</title>
		<link>http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/comment-page-1/#comment-1190</link>
		<dc:creator>Rusted</dc:creator>
		<pubDate>Tue, 13 Oct 2009 08:55:03 +0000</pubDate>
		<guid isPermaLink="false">http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/#comment-1190</guid>
		<description>Check this client too http://code.google.com/p/sphinx-dotnet-client/
It&#039;s open source and supports all latest features and Sphinx server protocols,  
ADO.NET like API. Provided with samples and Sphinx GUI index test tool.</description>
		<content:encoded><![CDATA[<p>Check this client too <a href="http://code.google.com/p/sphinx-dotnet-client/" rel="nofollow">http://code.google.com/p/sphinx-dotnet-client/</a><br />
It&#8217;s open source and supports all latest features and Sphinx server protocols,<br />
ADO.NET like API. Provided with samples and Sphinx GUI index test tool.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shaun</title>
		<link>http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/comment-page-1/#comment-1187</link>
		<dc:creator>Shaun</dc:creator>
		<pubDate>Mon, 05 Oct 2009 18:07:46 +0000</pubDate>
		<guid isPermaLink="false">http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/#comment-1187</guid>
		<description>Hey everyone, I re-wrote a .NET client for Sphinx from scratch this past weekend and have posted it up on Google Code (http://code.google.com/p/sphinxdotnet) Feel free to join the project and help out if you want. I think it is feature complete for the sphinxsearch trunk (release 2011)</description>
		<content:encoded><![CDATA[<p>Hey everyone, I re-wrote a .NET client for Sphinx from scratch this past weekend and have posted it up on Google Code (<a href="http://code.google.com/p/sphinxdotnet" rel="nofollow">http://code.google.com/p/sphinxdotnet</a>) Feel free to join the project and help out if you want. I think it is feature complete for the sphinxsearch trunk (release 2011)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill</title>
		<link>http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/comment-page-1/#comment-1180</link>
		<dc:creator>Bill</dc:creator>
		<pubDate>Fri, 28 Aug 2009 21:27:50 +0000</pubDate>
		<guid isPermaLink="false">http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/#comment-1180</guid>
		<description>One more piece:
public void SetFilterFloatRange(string attribute, float min, float max, bool exclude)
        {
		    Debug.Assert ( min&lt;=max, &quot;min must be less or equal to max&quot; );
		    try
		    {
                BinaryWriter bw = new BinaryWriter(_filterStreamData);
                WriteToStream(bw, attribute);
                WriteToStream(bw, SPH_FILTER_FLOATRANGE);
                WriteToStream(bw, min);
                WriteToStream(bw, max);
                WriteToStream(bw, exclude ? 1 : 0);
		    } 
            catch ( Exception e )
		    {
			    Debug.Assert ( false, &quot;IOException: &quot; + e.ToString() );
		    }
		    _filterCount++;
        }</description>
		<content:encoded><![CDATA[<p>One more piece:<br />
public void SetFilterFloatRange(string attribute, float min, float max, bool exclude)<br />
        {<br />
		    Debug.Assert ( min&lt;=max, &#8220;min must be less or equal to max&#8221; );<br />
		    try<br />
		    {<br />
                BinaryWriter bw = new BinaryWriter(_filterStreamData);<br />
                WriteToStream(bw, attribute);<br />
                WriteToStream(bw, SPH_FILTER_FLOATRANGE);<br />
                WriteToStream(bw, min);<br />
                WriteToStream(bw, max);<br />
                WriteToStream(bw, exclude ? 1 : 0);<br />
		    }<br />
            catch ( Exception e )<br />
		    {<br />
			    Debug.Assert ( false, &#8220;IOException: &#8221; + e.ToString() );<br />
		    }<br />
		    _filterCount++;<br />
        }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill</title>
		<link>http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/comment-page-1/#comment-1179</link>
		<dc:creator>Bill</dc:creator>
		<pubDate>Fri, 28 Aug 2009 21:01:09 +0000</pubDate>
		<guid isPermaLink="false">http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/#comment-1179</guid>
		<description>Also added UpdateAttributes API Call:

/**
	     * Connect to searchd server and update given attributes on given documents in given indexes.
	     * Sample code that will set group_id=123 where id=1 and group_id=456 where id=3:
	     *
	     * 
	     * String[] attrs = new String[1];
	     *
	     * attrs[0] = &quot;group_id&quot;;
	     * long[][] values = new long[2][2];
	     *
	     * values[0] = new long[2]; values[0][0] = 1; values[0][1] = 123;
	     * values[1] = new long[2]; values[1][0] = 3; values[1][1] = 456;
	     *
	     * int res = cl.UpdateAttributes ( &quot;test1&quot;, attrs, values );
	     * 
	     *
	     * @param index		index name(s) to update; might be distributed
	     * @param attrs		array with the names of the attributes to update
	     * @param values	array of updates; each long[] entry must contains document ID
	     *					in the first element, and all new attribute values in the following ones
	     * @return			-1 on failure, amount of actually found and updated documents (might be 0) on success
	     *
	     * @throws			SphinxException on invalid parameters
	     */
	    public int UpdateAttributes ( String index, String[] attrs, long[][] values )
	    {
		    /* check args */
		    Debug.Assert ( !string.IsNullOrEmpty(index), &quot;no index name provided&quot; );
		    Debug.Assert ( attrs!=null &amp;&amp; attrs.Length&gt;0, &quot;no attribute names provided&quot; );
		    Debug.Assert ( values!=null &amp;&amp; values.Length&gt;0, &quot;no update entries provided&quot; );
		    for ( int i=0; i&lt;values.Length; i++ )
		    {
			    Debug.Assert ( values[i]!=null, &quot;update entry #&quot; + i + &quot; is null&quot; );
			    Debug.Assert ( values[i].Length == 1 + attrs.Length, &quot;update entry #&quot; + i + &quot; has wrong length&quot; );
		    }

		    /* build and send request */
            if (_client == null &#124;&#124; !_client.Connected)
            {
                this.Connect();
            }
            if (_client == null) return -1;
            StreamReader sr = new StreamReader(_client.GetStream());
            BinaryWriter sw = new BinaryWriter(_client.GetStream());
            BinaryWriter tsw = new BinaryWriter(new MemoryStream()); /* temp command buffer */
		    try
		    {
                WriteToStream(sw, VER_MAJOR_PROTO);
                WriteToStream(sw, (short)SEARCHD_COMMAND_UPDATE);
                WriteToStream(sw, (short)VER_COMMAND_UPDATE);
                this.WriteToStream(tsw, index);
                this.WriteToStream(tsw, attrs.Length);
                for (int i = 0; i&lt; attrs.Length; i++)
                {
                    this.WriteToStream(tsw, attrs[i]);
                }

                this.WriteToStream(tsw, values.Length);

                for (int i = 0; i &lt; values.Length; i++)
                {
                    this.WriteToStream(tsw, values[i][0]); /* send docid as 64bit value */
                    for (int j = 1; j &lt; values[i].Length; j++)
                    {
                            this.WriteToStream(tsw, (int)values[i][j]); /* send values as 32bit values; FIXME! what happens when they are over 2^31? */
                    }
                }

                this.WriteToStream(sw, (int)tsw.BaseStream.Length); // send the request size
                sw.Write(((MemoryStream)tsw.BaseStream).ToArray());
                sw.Flush();

		    } catch ( Exception e )
		    {
			    _error = &quot;internal error: failed to build request: &quot; + e;
			    return -1;
		    }

		    /* get and parse response */
		    byte[] response = GetResponse(_client, VER_COMMAND_UPDATE);
            if ( response == null )
			    return -1;

		    try
		    {
                BinaryReader br = new BinaryReader(new MemoryStream(response));
                return this.ReadInt32(br);
		    } catch ( Exception  )
		    {
			    _error = &quot;incomplete reply&quot;;
			    return -1;
		    }
	    }</description>
		<content:encoded><![CDATA[<p>Also added UpdateAttributes API Call:</p>
<p>/**<br />
	     * Connect to searchd server and update given attributes on given documents in given indexes.<br />
	     * Sample code that will set group_id=123 where id=1 and group_id=456 where id=3:<br />
	     *<br />
	     *<br />
	     * String[] attrs = new String[1];<br />
	     *<br />
	     * attrs[0] = &#8220;group_id&#8221;;<br />
	     * long[][] values = new long[2][2];<br />
	     *<br />
	     * values[0] = new long[2]; values[0][0] = 1; values[0][1] = 123;<br />
	     * values[1] = new long[2]; values[1][0] = 3; values[1][1] = 456;<br />
	     *<br />
	     * int res = cl.UpdateAttributes ( &#8220;test1&#8243;, attrs, values );<br />
	     *<br />
	     *<br />
	     * @param index		index name(s) to update; might be distributed<br />
	     * @param attrs		array with the names of the attributes to update<br />
	     * @param values	array of updates; each long[] entry must contains document ID<br />
	     *					in the first element, and all new attribute values in the following ones<br />
	     * @return			-1 on failure, amount of actually found and updated documents (might be 0) on success<br />
	     *<br />
	     * @throws			SphinxException on invalid parameters<br />
	     */<br />
	    public int UpdateAttributes ( String index, String[] attrs, long[][] values )<br />
	    {<br />
		    /* check args */<br />
		    Debug.Assert ( !string.IsNullOrEmpty(index), &#8220;no index name provided&#8221; );<br />
		    Debug.Assert ( attrs!=null &amp;&amp; attrs.Length&gt;0, &#8220;no attribute names provided&#8221; );<br />
		    Debug.Assert ( values!=null &amp;&amp; values.Length&gt;0, &#8220;no update entries provided&#8221; );<br />
		    for ( int i=0; i&lt;values.Length; i++ )<br />
		    {<br />
			    Debug.Assert ( values[i]!=null, &#8220;update entry #&#8221; + i + &#8221; is null&#8221; );<br />
			    Debug.Assert ( values[i].Length == 1 + attrs.Length, &#8220;update entry #&#8221; + i + &#8221; has wrong length&#8221; );<br />
		    }</p>
<p>		    /* build and send request */<br />
            if (_client == null || !_client.Connected)<br />
            {<br />
                this.Connect();<br />
            }<br />
            if (_client == null) return -1;<br />
            StreamReader sr = new StreamReader(_client.GetStream());<br />
            BinaryWriter sw = new BinaryWriter(_client.GetStream());<br />
            BinaryWriter tsw = new BinaryWriter(new MemoryStream()); /* temp command buffer */<br />
		    try<br />
		    {<br />
                WriteToStream(sw, VER_MAJOR_PROTO);<br />
                WriteToStream(sw, (short)SEARCHD_COMMAND_UPDATE);<br />
                WriteToStream(sw, (short)VER_COMMAND_UPDATE);<br />
                this.WriteToStream(tsw, index);<br />
                this.WriteToStream(tsw, attrs.Length);<br />
                for (int i = 0; i&lt; attrs.Length; i++)<br />
                {<br />
                    this.WriteToStream(tsw, attrs[i]);<br />
                }</p>
<p>                this.WriteToStream(tsw, values.Length);</p>
<p>                for (int i = 0; i &lt; values.Length; i++)<br />
                {<br />
                    this.WriteToStream(tsw, values[i][0]); /* send docid as 64bit value */<br />
                    for (int j = 1; j &lt; values[i].Length; j++)<br />
                    {<br />
                            this.WriteToStream(tsw, (int)values[i][j]); /* send values as 32bit values; FIXME! what happens when they are over 2^31? */<br />
                    }<br />
                }</p>
<p>                this.WriteToStream(sw, (int)tsw.BaseStream.Length); // send the request size<br />
                sw.Write(((MemoryStream)tsw.BaseStream).ToArray());<br />
                sw.Flush();</p>
<p>		    } catch ( Exception e )<br />
		    {<br />
			    _error = &#8220;internal error: failed to build request: &#8221; + e;<br />
			    return -1;<br />
		    }</p>
<p>		    /* get and parse response */<br />
		    byte[] response = GetResponse(_client, VER_COMMAND_UPDATE);<br />
            if ( response == null )<br />
			    return -1;</p>
<p>		    try<br />
		    {<br />
                BinaryReader br = new BinaryReader(new MemoryStream(response));<br />
                return this.ReadInt32(br);<br />
		    } catch ( Exception  )<br />
		    {<br />
			    _error = &#8220;incomplete reply&#8221;;<br />
			    return -1;<br />
		    }<br />
	    }</p>
]]></content:encoded>
	</item>
</channel>
</rss>

