Reputation: 7
I am trying to create a basic Lucene index in eXist-db. I do not see the index in the list of indexes using Monex and the index doesn't work when I query it. But when I reindex it returns "true()" when I run it manually or if I save the collection.xconf it says "Configurations applied".
My XML looks like this:
<TEI xmlns="http://www.tei-c.org/ns/1.0" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<text>
<body>
<superEntry xml:id="f1755-z-1-se">
<entry xml:id="f1755-z-1" corresp="#f1773-z-1">
<pb facs="f1755-z-1.jpg"/>
<form type="variant">Z,</form>
<sense xml:id="f1755-z-1.1" n="1">
<def>Is found in the <lang ana="#ang">Saxon</lang> alphabets, set down by Grammarians, but is read in no word originally <lang ana="#gem">Teutonick</lang>:</def>
<note type="pron">its sound is uniformly that of an hard S.</note>
</sense>
</entry>
</superEntry>
</body>
</text>
</TEI>
My index is like this:
<collection xmlns="http://exist-db.org/collection-config/1.0">
<index xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<lucene>
<analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
<text qname="tei:def"/>
<inline qname="tei:hi"/>
</lucene>
</index>
The lucene query here returns nothing, but the other contains query returns results:
xquery version "3.1";
declare namespace tei="http://www.tei-c.org/ns/1.0";
let $query :=
<query>
<term>found</term>
</query>
return
collection('/db/apps/sjd/data')//tei:def[ft:query(.,$query)],
collection('/db/apps/sjd/data')//tei:def[contains(.,"found")]
Is there an error in the index definition or query? What am I missing? Is there a way to see if indexes exist, other than the Monex indexes page? Thank you in advance.
Upvotes: 0
Views: 322
Reputation: 159
ft:query
), so you have to "import" it in your code.for
to query your collection and only then return
to show result one by one (see explanations about XQuery FLWOR
)."[...] indexes are configured in collection-specific configuration files. These files are stored as standard XML documents in the system collection /db/system/config [...] To configure a given collection, for instance /db/foo, create a file collection.xconf and store it as /db/system/config/db/foo/collection.xconf. "
<term>
inside <bool>
.So try to check if you index is in the right place and then try this code:
xquery version "3.1";
declare namespace tei="http://www.tei-c.org/ns/1.0";
import module namespace kwic="http://exist-db.org/xquery/kwic";
let $query :=
<query>
<bool>
<term>found</term>
</bool>
</query>
for $hit in collection('/db/apps/sjd/data')//tei:def[ft:query(.,$query)]
return
kwic:summarize($hit, <config width="40"/>)
Finally, do not hesitate to look at the documentation for more details: eXist-db KWIC and eXist-db Fulltext index and search
UPDATE: Your index miss the final close tag </collection>
Upvotes: 1
Reputation: 7
I found the problem and it is reproducible. If you create an XML formatting syntax error in an index configuration and then reindex, the index disappears from the Monex list of indexes and there is nothing you can do to the file make the index compile. I kept trying to modify the index configuration and it did not look like there was any error, but the index never showed in the Monex list of indexes.
To fix it,
Upvotes: 0