This is a refinement on the question I asked the other day. I'm
getting better at formulating my questions so maybe the advise might be
closer :)
Suppose I do a query and get a XML document which has a field that has
text that looks like this :
"The anterior glandular lobe of the pituitary gland, also known as the
adenohypophysis. It secretes the ADENOHYPOPHYSEAL HORMONES that regulate
vital functions such as GROWTH; METABOLISM; and REPRODUCTION."
Those things in all upper case are likely terms that exist in other
documents.
What I'd like to do is to do a search for each of those terms across the
entire DB, and if found, create links to either the highest scored find,
or to a results page (either will do).
I've poked around and found many little things that are part of a
possible solution, but nothing that does exactly what I want.
For example: cts:hilight() could be used to add the links to the words.
and I could find a consolidated result set by using
cts:search( ... , cts:word-query ( fn:tokenize(phrase) ) )
to find all matches etc. I an easily get all the upper case words and
create a search.
But my problem is this. Suppose I create a search on all the upper case
words ("ADENOHYPOPHYSEAL" , "GROWTH" , "METABOLISM")
and get a result back with cts:search()
How can I match up Which nodes of the result matched which word so I can
hilight them ?
e.g if I did
for $result in cts:search( ..... all the words )
// Which word did $result match ???
My only thing I can think of is that i would have to iteratively loop
through the terms and do a search one by one.
for $word in ( big oh list of search words )
for $result in cts:search( ... , $word )
cts:hilight( $phrase , $word , { link the word } )
My guess is that this will perform horribly. I'd rather get a single
consolidated search then do some magic like
for $result in cts:search( ... , all the words )
cts:hilight( $phrase , the word that matched $result )
Does this make any sense ? Is there an API or design pattern to do this
? Or should I do the outer loop instead ?
I looked at cts:walk but it looked like it to use it for this would
still involve looping on the cts:search() for each term matched.
Thanks for any advise.
----------------------------------------
David A. Lee
Senior Principal Software Engineer
Epocrates, Inc.
[email protected] <mailto:[email protected]>
812-482-5224
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general