Database Reference
In-Depth Information
3. Call the ft:index function to create the index for this specific resource:
ft:index ( $ resource , $ index-def )
Now Lucene creates an index with two subindexes (fields). It indexes all the text
fragments passed in the doc/field elements and stores this information, together
with the indexed text (because the store attribute is set to "yes" ).
If you don't store the text (by setting the store attribute to "no" ), the text is
indexed but cannot be retrieved. The only thing you can do with an index
without stored text is find out whether or not a certain phrase is present; you
can't get its context.
4. Using such an index is done via the extension function ft:search . The search
expression passed must contain the field name as a prefix. So, for instance, to
search the paragraphs for the word eXist , you would do something like this:
ft:search ( $ resource , 'paras:eXist' )
Which would return an XML fragment like:
<Indexing file= "/db/path/to/your/xhtml/document" >
<results>
<search uri= "/db/path/to/your/xhtml/document" score= "0.5260675" >
<field name= "paras" > Please use
<exist:match xmlns:exist= "http://exist.sourceforge.net/NS/exist" >
eXist </exist:match>
for storing your information. You know why!
</field>
</search>
</results>
</Indexing>
Information about the meaning of the score attribute can be found in “Scoring
Searches” on page 296 .
An interesting use case for this manual index creation is that of indexing binary con‐
tent. You do so by first extracting the content from the binary resource using the
contentextraction extension module (see contentextraction ), then creating an
index for it as just described. The topic's sample code contains a short example of
how to do this in the chapters/indexing/index-binary.xq file (or in the /db/apps/exist-
book/chapters/indexing/index-binary.xq file if you have installed the XAR package).
There is also an interesting article about content extraction and binary resource
indexing available on the eXist wiki .
Search WWH ::




Custom Search