Re: [basex-talk] Is it right query using ft:search ?
Hi Dirk, Thanks for your reply.. What will be the query for the following structure - I tried your yesterday's query it achieved the result as required. My structure was not exactly the same as mentioned yesterday. I thought, I would modify it as per my structure. But, I was not successful. Below is my complete structure. I want to search the MainDesc, which have 2 child nodes viz; shortDesc and longDesc. <Docs> <Doc> <DocTitle C="1"></DocTitle> <MainDesc> <shortDesc></shortDesc> <longDesc> some text <B>to make the word(s) bold Optional</B> some text <I>to make the word(s) italic Optional</I> some text <U>to have an underline Optional</U> some text some text </longDesc> </MainDesc> <FullDesc></FullDesc> </Doc> </Docs> ------------------------------------------------------------------------- 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 -- Have a nice day JBest
Hi John, the query should be basically be the same, but with the now given structure you should rather use ancestor instead of parent, as the structure is not exactly known and where search hits might occur. So it should be: for $x in ft:search("docMaster", ("emf","waves"), map{'mode':='all words'})/ancestor::*:MainDesc/parent::*:Doc return $x/DocTitle/text() Please be also aware of the restrictions if you are searching within mixed content, e.g. when searching for "text" and "to" it will not return any match for this data. See https://docs.basex.org/wiki/Full-Text#Mixed_Content for more information. Cheers, Dirk On 20/11/13 06:11, John Best wrote:
Hi Dirk,
Thanks for your reply.. What will be the query for the following structure -
I tried your yesterday's query it achieved the result as required. My structure was not exactly the same as mentioned yesterday. I thought, I would modify it as per my structure. But, I was not successful. Below is my complete structure.
I want to search the MainDesc, which have 2 child nodes viz; shortDesc and longDesc.
<Docs> <Doc> <DocTitle C="1"></DocTitle> <MainDesc> <shortDesc></shortDesc> <longDesc> some text <B>to make the word(s) bold Optional</B> some text <I>to make the word(s) italic Optional</I> some text <U>to have an underline Optional</U> some text some text </longDesc> </MainDesc> <FullDesc></FullDesc> </Doc> </Docs>
-------------------------------------------------------------------------
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
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
-- Dirk Kirsten, BaseX GmbH, http://basex.org |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
participants (2)
-
Dirk Kirsten -
John Best