Thanks, Christian. The following works as expected (the output contains the matches with their surrounding context)

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 ft:extract($study//*[text() contains text { 'genomics', 'genomic', 'transcriptome', 'exome', 'whole genome', 'microarray', 'proteome', 'metabolome' }])

Is it possible to combine the two patterns (i.e., the selection criteria and the extraction in the return) into a single one?

Perhaps this is what ft:mark is supposed to do but I could not get it to work...

Best,
Ron

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
>