SOLVED: Problems with ft:query / Lucene indexer
Update to the post below: this problem was solved on advice from JW on the eXist list, to move the tei xmlns attribute in collection.xconf from the root <collection> element to the child <index> element.
Began working on the Search textbox, which I was going to base on the Lucene index, but after setting up the appropriate collection.xconf and re-indexing, I was unable to make it work. After trying to debug this for a while, I ended up posting a message to the eXist list, which I'll reproduce here because it explains the problem clearly:
When I run this query:
declare default element namespace "http://www.tei-c.org/ns/1.0";
declare namespace ft = "http://exist-db.org/xquery/lucene";
for $p in collection('/db/myndir/names/')//person[ft:query(., "killed")]
return $p
I get no results, but when I run this:
for $p in collection('/db/myndir/names/')//tei:person[contains(., "killed")]
return $p
I get 11 results, as expected. Can anyone suggest what the problem might be?
This is the setup:
eXist was built with Cocoon, with Lucene enabled in build.properties:
include.index.lucene = true
The exist-lucene-module.jar file is present, and Lucene is enabled in conf.xml:
<module id="lucene-index" class="org.exist.indexing.lucene.LuceneIndex" buffer="32"/>
<modules>
<module id="lucene-index"
class="org.exist.indexing.lucene.LuceneIndex" buffer="32"/>
...
</modules>
...
<builtin-modules>
<module id="lucene-index"
class="org.exist.indexing.lucene.LuceneIndex"/>
...
</builtin-modules>
I have the following collections.xconf file at /db/system/config/db/myndir/names/:
<?xml version="1.0" encoding="UTF-8"?>
<collection xmlns="http://exist-db.org/collection-config/1.0"
xmlns:tei="http://www.tei-c.org/ns/1.0">
<index>
<!-- Old full text index configuration. Deprecated. -->
<fulltext default="none" attributes="no">
</fulltext>
<!-- New full text index based on Lucene -->
<lucene>
<analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
<analyzer id="ws" class="org.apache.lucene.analysis.WhitespaceAnalyzer"/>
<text qname="tei:person"/>
</lucene>
<!-- Range indexes -->
<create qname="tei:person" type="xs:string"/>
</index>
</collection>
and I have re-indexed the collection. eXist does not appear to be writing any logs, other than a large binary file called "0000000043.log" which is in WEB-INF/data. Cocoon's log doesn't show anything useful.
I have no idea why logging isn't working here. That's something we probably want to tackle, but I have no idea where to start. We also should probably consider building another eXist-1.4 + Cocoon using our build script, in case anything major has been fixed since December, but I'll wait for the response on the eXist list to see if that might help; we have so many projects already using our original build that the time investment in porting would be considerable.