Hello John,
I guess your second query isn't really doing what you intend it to do. Actually, it will yield the same output as your first query (the child step /MainDesc will only have the effect that fragments without MainDesc as a child will be filtered out). I guess the following query should work (at least if I understood correctly what you are trying to achieve):
for $x in ft:search("docMaster", ("emf","waves"), map{'mode':='all words'})/parent::*:MainDesc/parent::*:Doc return $x/DocTitle/text()
Thereby, you using the parent step you assure that the found text node was actually inside a MainDesc node.
Please also note that there is a difference between an ancestor step and a parent step and as you seem to know your structure it might be easier and faster to simply use parent.
Cheers, Dirk
On 19/11/13 09:08, John Best wrote:
Hi Team,
Below is my XML Structure -
<Docs> <Doc> <DocTitle C="1"></DocTitle> <MainDesc></MainDesc> <FullDesc></FullDesc> </Doc> <Doc> <DocTitle C="2"></DocTitle> <MainDesc></MainDesc> <FullDesc></FullDesc> </Doc> ............ ............
</Docs>
I have to search the Full Text DB of above documents with 3 different options -
Complete Document
Only in MainDesc (Main Description)
Only in FullDesc (Full Description)
Below is the query, using ft:search, for the first options, mentioned above
for $x in ft:search("docMaster", ("emf","waves"), map{'mode':='all words'})/ancestor::*:Doc return $x/DocTitle/text()
Now, this is for the 2nd options, i.e; for MainDesc -
for $x in ft:search("docMaster", ("emf","waves"), map{'mode':='all words'})/ancestor::*:Doc/MainDesc return $x/DocTitle/text()
Is it right ? I am little bit confused..
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk