Tokenize..
Saturday, 13 April 2013 · 3 messages · last reply 14 Apr 2013
JB
John Best13 Apr 2013 06:32 #
Hi there,
The structure of my XML DB (Docs) is -
<Docs>
<Doc>
<Info></Info>
<Desc></Desc>
</Doc>
</Docs>I want to create tokens, so I will be using
ft:tokens('Docs'). This will create tokens for all the available nodes.
I want to create tokens for the Info Node only... How to ,,?--
Have a nice day
JBest
CG
Christian Grün13 Apr 2013 23:26 #
Hi John,
to give you a somewhat satisfying answer, I’m afraid I need more details.
Quoted text · John Best · 3 lines
> I want to create tokens, so I will be using ft:tokens('Docs'). > This will create tokens for all the available nodes. > I want to create tokens for the Info Node only... How to ,,?
The result of
ft:tokens() will contain all tokens that are stored in the full-text index of the addressed database. At this point I’m stuck, because I can’t guess what you mean with "Info Node"?
Best,
ChristianCG
Christian Grün14 Apr 2013 14:09 #
Quoted text · Christian Grün · 1 line
> With "Info Node", I mean that I want to have tokens for a specific node. !!
Got it. You’ll have to retrieve the text of this node and call
ft:tokenize(). An example: for $x in //text()
return ft:tokenize($x)Please note that the tokenize function won’t aggregate the tokens. You could try the following XQuery code to get a similar output (note that this particular example only works with 7.7, which includes support for general FLWOR expressions):
let $text := 'a b a'
for $words in ft:tokenize($text)
group by $w := $words
let $count := count($words)
order by $count descending
return <entry count="{ $count }">{ $w }</entry>Quoted text · Christian Grün · 26 lines
> On Sun, Apr 14, 2013 at 2:56 AM, Christian Grün <christian.gruen at gmail.com> > wrote: >> >> Hi John, >> >> to give you a somewhat satisfying answer, I’m afraid I need more details. >> >> > I want to create tokens, so I will be using ft:tokens('Docs'). >> > This will create tokens for all the available nodes. >> > I want to create tokens for the Info Node only... How to ,,? >> >> The result of ft:tokens() will contain all tokens that are stored in >> the full-text index of the addressed database. At this point I’m >> stuck, because I can’t guess what you mean with "Info Node"? >> >> Best, >> Christian > > > > > -- > Have a nice day > JBest > >
Written for BaseX 7.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery