<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ian Winter &#187; mva</title>
	<atom:link href="http://ianwinter.co.uk/tag/mva/feed/" rel="self" type="application/rss+xml" />
	<link>http://ianwinter.co.uk</link>
	<description>Have you found the instructions yet?</description>
	<lastBuildDate>Sun, 05 Sep 2010 19:53:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Sphinx Multi-Value Attributes</title>
		<link>http://ianwinter.co.uk/2009/07/06/sphinx-multi-value-attributes/</link>
		<comments>http://ianwinter.co.uk/2009/07/06/sphinx-multi-value-attributes/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 10:03:18 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mva]]></category>
		<category><![CDATA[sphinx]]></category>

		<guid isPermaLink="false">http://ianwinter.co.uk/?p=1054</guid>
		<description><![CDATA[Sphinx allows you to create a multi-value attribute index which is great for document tags or categories. By default if you search across these the search is an OR match. If you want to run an AND match you must specify multiple filters rather than passing an array of values. In ColdFusion using the Java [...]]]></description>
			<content:encoded><![CDATA[<p>Sphinx allows you to create a multi-value attribute index which is great for document tags or categories. By default if you search across these the search is an OR match. If you want to run an AND match you must specify multiple filters rather than passing an array of values.</p>
<p>In ColdFusion using the Java API requires a little tweak as you can&#8217;t pass a normal ColdFusion array to sphinx, you have to use a basic java type array. Tim Blair has a <a href="http://tim.bla.ir/tech/articles/cf-and-arrays-of-basic-java-types" target="_blank">good article</a> on how to create them but here&#8217;s an example of calling the API.</p>
<p>This example will search for document tagged with either 100 or 200. Note the array creation method.</p>
<p><code>&lt;cfset variables.sphinx = createobject("java", "org.sphx.api.SphinxClient").init()&gt;<br />
&lt;cfset variables.sphinx.SetLimits(0, 10)&gt;<br />
&lt;cfset variables.arrObj = createobject("java", "java.lang.reflect.Array")&gt;<br />
&lt;cfset variables.jClass = createobject("java", "java.lang.Integer").TYPE&gt;<br />
&lt;cfset variables.jArr = variables.arrObj.newInstance(variables.jClass, 2)&gt;<br />
&lt;cfset variables.arrObj.setInt(variables.jArr, 0, 100)&gt;<br />
&lt;cfset variables.arrObj.setInt(variables.jArr, 1, 200)&gt;<br />
&lt;cfset variables.sphinx.SetFilter("tag", variables.jArr, FALSE)&gt;</code></p>
<p>If you want to search for 100 AND 200 you&#8217;d do it like this:</p>
<p><code>&lt;cfset variables.sphinx = createobject("java", "org.sphx.api.SphinxClient").init()&gt;<br />
&lt;cfset variables.sphinx.SetLimits(0, 10)&gt;<br />
&lt;cfset variables.sphinx.SetFilter("tag", 100, FALSE)&gt;<br />
&lt;cfset variables.sphinx.SetFilter("tag", 200, FALSE)&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://ianwinter.co.uk/2009/07/06/sphinx-multi-value-attributes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
