Hi Ron,
Is it possible to combine the two patterns (i.e., the selection criteria and the extraction in the return) into a single one?
ft:extract works the same as ft:mark, but it additionally chops your results down to the relevant parts of the result.
Here are two ways how to shorten your query:
(: Variant 1 :) let $terms := ('genomics', 'genomic') for $study in db:open('CTGov')/clinical_study//* [text() contains text { $terms }] return ft:extract($study[text() contains text { $terms }])
(: Variant 2 :) let $terms := ('genomics', 'genomic') return ft:extract(db:open('CTGov')/clinical_study//* [text() contains text { $terms }])
Christian
On December 10, 2015 at 11:24:38 AM, Christian Grün (christian.gruen@gmail.com) wrote:
Hi Ron,
You can use ft:mark and ft:extract to highlights matches in a full-text result [1].
Hope this helps, Christian
[1] http://docs.basex.org/wiki/Full-Text_Module#ft:mark
On Thu, Dec 10, 2015 at 4:33 PM, Ron Katriel rkatriel@mdsol.com wrote:
Hi,
Is there a way to return all matches when searching a large XML structure? For example, return the genomic keywords that matched anywhere in $study using the following query:
for $study in db:open('CTGov')/clinical_study let $result := $study contains text { 'genomics', 'genomic', 'transcriptome', 'exome', 'whole genome', 'microarray', 'proteome', 'metabolome' } let score $score := $result where $score >= 0.01 return $study/id_info/nct_id (: this is just the Study ID :)
Ideally it would include an indication of where in the tree the matches are (e.g., that ‘exome’ was found in $study/official_title and in $article/keywords).
This could presumably be done using regular expression matching (after serializing the tree into a text string) but it does not seem an elegant solution.
Thanks, Ron