{"id":363,"date":"2003-04-24T01:49:20","date_gmt":"2003-04-24T05:49:20","guid":{"rendered":"http:\/\/wordpress.cephas.net\/?p=363"},"modified":"2003-04-24T01:49:20","modified_gmt":"2003-04-24T05:49:20","slug":"cfx_lucene","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2003\/04\/24\/cfx_lucene\/","title":{"rendered":"CFX_LUCENE"},"content":{"rendered":"<p>I mentioned <a href=\"http:\/\/www.macromedia.com\/software\/drk\/productinfo\/product_overview\/volume3\/coldfusionmx.html#lindex\">Lindex<\/a> (described as a &#8220;&#8230; high performance, full-featured text search engine that allows developers to create document collections for easy indexing and quick searching&#8221; two days <a href=\"http:\/\/cephas.net\/blog\/archives\/000369.html#000369\">ago<\/a>.  After inspecting it a bit further, it looks like it offers an interface for developers to create and maintain <a href=\"http:\/\/jakarta.apache.org\/lucene\/docs\/index.html\">Lucene<\/a> indexes using ColdFusion (and I&#8217;m guessing allows them to search indexes as well), which is a nice feature.. I&#8217;d love to see it. <\/p>\n<p>Anyway, inspired by Lindex, tonight I hacked together a <a href=\"http:\/\/livedocs.macromedia.com\/cfmxdocs\/CFML_Reference\/CFXRef_Java.jsp\">Java CFX<\/a> tag that closely mimics the the <a href=\"http:\/\/livedocs.macromedia.com\/cfmxdocs\/CFML_Reference\/Tags-pt3.jsp#1103106\">&lt;cfsearch&gt;<\/a> tag using Lucene as the search engine.  You can download the Java source <a href=\"\/images\/files\/lucene.java\">here<\/a> <b>[ update 11\/04\/2003: <a href=\"http:\/\/www.torchbox.com\/people\/nick\/index.html\">Nick Burch<\/a> from torchbox.com sent me an updated version that &#8220;<i>behaves better under error conditions and &#8230; the command line debug now works<\/i>&#8220;, thanks Nick!, clicking on the &#8216;lucene.java&#8217; link above will download the updated version ]<\/b>. <\/p>\n<p>To compile it, you&#8217;ll have to add both the cfx.jar file (usually in \\CFusionMX\\lib\\cfx.jar) and the lucene.jar (get yours <a href=\"http:\/\/jakarta.apache.org\/builds\/jakarta-lucene\/release\/v1.2\/\">here<\/a>) file to your classpath manually or specify them at compile time. If you&#8217;re compiling from the command line, it might look something like this:<\/p>\n<p>$ javac -classpath c:\\cfusionmx\\lib\\cfx.jar;c:\\lucene\\lucene.jar lucene.java<\/p>\n<p>After you compile the class, you&#8217;ll need to <\/p>\n<p>a) copy it to a directory that ColdFusion is aware of (ie: \/cfide\/administrator\/ &#8211;&gt; Java and JVM &#8211;&gt; Class Path)<\/p>\n<p>b) add the lucene.jar to the Class Path mentioned in &#8216;a&#8217;<\/p>\n<p>c) register the CFX in the ColdFusion Administrator (\/cfide\/administrator\/ &#8211;&gt; Extensions &#8211;&gt; CFX Tags.  Click on &#8216;Register Java CFX&#8217;.  The tag name should be &#8216;cfx_lucene&#8217;, the class name should be &#8216;lucene&#8217;.<\/p>\n<p>d) restart CFMX.<\/p>\n<p>e) and finally, create a .cfm page and add this script:<\/p>\n<p>&lt;cfx_lucene<br \/>\n&nbsp;&nbsp;query=&#8221;r_query&#8221;<br \/>\n&nbsp;&nbsp;indexName=&#8221;C:\\hosts\\cephas.net\\wwwroot\\blog\\index&#8221;<br \/>\n&nbsp;&nbsp;startIndex=&#8221;1&#8243;<br \/>\n&nbsp;&nbsp;maxPage=&#8221;10&#8243;<br \/>\n&nbsp;&nbsp;queryString=&#8221;java&#8221;&gt;<\/p>\n<p>The above script presumes that you have a Lucene index already created in the directory &#8216;C:\\hosts\\cephas.net\\wwwroot\\blog\\index&#8217;,  is looking for the keyword &#8216;java&#8217;, and will return a ColdFusion query object to the template with the columns &#8216;title&#8217;, &#8216;url&#8217;, and &#8216;summary&#8217;.<\/p>\n<p>To see the results, you can dump the CFDUMP tag:<\/p>\n<p>&lt;cfdump var=&#8221;#r_query#&#8221;&gt;<\/p>\n<p>Caveat: It&#8217;s 1:42amEST so I&#8217;ve done no testing on it and it has no interface (like I&#8217;m sure Lindex does).  Use at your own risk. If you do use it, please keep my name\/email in the source somewhere and remember to thank <a href=\"http:\/\/www.joecheng.com\/\">Joe<\/a> for the <a href=\"http:\/\/cephas.net\/blog\/archives\/000310.html#000310\">idea<\/a>.  Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I mentioned Lindex (described as a &#8220;&#8230; high performance, full-featured text search engine that allows developers to create document collections for easy indexing and quick searching&#8221; two days ago. After inspecting it a bit further, it looks like it offers an interface for developers to create and maintain Lucene indexes using ColdFusion (and I&#8217;m guessing &hellip; <a href=\"https:\/\/cephas.net\/blog\/2003\/04\/24\/cfx_lucene\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">CFX_LUCENE<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,19],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/363"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=363"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/363\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}