I'm trying to create a Lucene index via Railo (cfindex doesn't seem
flexible enough for what I need - or perhaps I just don't know how to
use it correctly) and am getting a 'no matching constructor' error.
My code is as follows (and was working fine in a JSP page but doesn't
seem to want to play under Railo):
[code above this to query database into qData, create
StandardAnalyzer, IndexWriter - all working fine]
<cfset vField=CreateObject("java","org.apache.lucene.document.Field")>
<cfloop query="qData">
<!--- create the document [works OK] --->
<cfset vDoc=CreateObject
("java","org.apache.lucene.document.Document")>
<!--- add fields to document [fails with 'No matching
constructor' no matter what I use] --- >
<cfset vDoc.add(vField.Text("id", qData.id))>
Where qData is a database query returning the id column from a
database table (it is returning other columns too but as it won't even
insert one field I haven't shown the others in the code above).
I have also tried
<cfset vDoc.add(vField.Text("id", "test"))>
<cfset vDoc.add(vField("id", qData.id, vField.Store.YES,
vField.Index.NO)> [this is the one that works in JSP]
Has anyone else come across this problem?
Any ideas?
Cheers
Bry
<cfset analyzer = createObject("java",
variables.storeConfig.getProperty("analyzerClass")).init()/>
<cfset iwriter = createObject("java",
"org.apache.lucene.index.IndexWriter").init
(variables.storeConfig.getProperty("indexStore"), analyzer, javaCast
("boolean", arguments.replaceIndex))/>
<cfset FieldStore = createObject("java",
"org.apache.lucene.document.Field$Store")>
<cfset FieldIndex = createObject("java",
"org.apache.lucene.document.Field$Index")>
<cfloop from="1" to="#arguments.data.recordCount#" index="i">
<cfset doc = createObject("java",
"org.apache.lucene.document.Document").init()/>
<cfset field = createObject("java",
"org.apache.lucene.document.Field")>
<cfif searchField.getIndexMethod() eq "keyword">
<cfset field.init(searchField.getName(), javaCast
(searchField.getJavaType(), searchData), FieldStore.YES,
FieldIndex.UN_TOKENIZED )>
<cfelseif searchField.getIndexMethod() eq "unindexed">
<cfset field.init(searchField.getName(), javaCast
(searchField.getJavaType(), searchData), FieldStore.YES,
FieldIndex.NO )>
<cfelseif searchField.getIndexMethod() eq "unstored">
<cfset field.init(searchField.getName(), javaCast
(searchField.getJavaType(), searchData), FieldStore.NO,
FieldIndex.TOKENIZED )>
<cfelseif searchField.getIndexMethod() eq "text">
<cfset field.init(searchField.getName(), javaCast
(searchField.getJavaType(), searchData), FieldStore.YES,
FieldIndex.TOKENIZED )>
</cfif>
<cfset doc.add(field)>
</cfloop>
<cfset iwriter.addDocument(doc)/>
<cfset documentsAdded = documentsAdded + 1/>
</cfloop>
<cfset iwriter.optimize()>
<cfset iwriter.close()/>
On 21 Jan., 16:20, AJ Mercer <ajmer...@gmail.com> wrote:
> With CFML there are two tags to handle the search collections - cfindex and
> cfsearch
>
> check out
> http://wiki.getrailo.org/wiki/3-1-Tags:CFIndex
>
> 2010/1/21 flashbry <lewisthebo...@googlemail.com>
I've had a go with cfindex and cfsearch and while they are great for
simple search collections (a la verity), they do not seem to offer
enough flexibility for the kinds of indexes I am required to build.
Each of the indexes I need to build may need to have upto 10 fields
and searches will need to be performed on any of those fields
(preferably with the field name specified in the search criteria e.g
'ID:1 and NAME:Bryan') which is why I was trying to access the Lucene
API directly.
Looks like I may just have to go back to JSP for it unless anyone has
any other ideas?
Using a database instead of creating a large index is not an option,
sadly.
Cheers
Bry.
On Jan 21, 3:20 pm, AJ Mercer <ajmer...@gmail.com> wrote:
> With CFML there are two tags to handle the search collections - cfindex and
> cfsearch
>
> check out
> http://wiki.getrailo.org/wiki/3-1-Tags:CFIndex
>
> 2010/1/21 flashbry <lewisthebo...@googlemail.com>
That works perfectly.
Thank you so much, you've saved me ripping all my hair out :0)
Cheers
Bry.