Hi Joshil,

I’m not sure I completely understand what you want to do, but here are a couple 
of ideas:

Each <result> that comes back from search:search represents a document or 
fragment in your database.  So if you have one sample document in your database 
(and it isn’t fragmented), then search:search(“wine”) will return just one 
<result> element.  Using <max-matches> only controls the number of matching 
nodes returned as part of the snippet;  it won’t change the number of <result> 
elements that are returned.

In order to restrict the search to terms in the <title> element, you need to 
construct an options node that defines a word constraint on the title element; 
that will allow you to write a search like:  search:search(“title:wine”) and 
get documents that have “wine” only in the title element.

The result element includes a document URI and path, so that you can access the 
document and use xpath on it to get the value of the <title> tag, which you can 
then display along with the snippet.  There is currently no way to include the 
value of the <title> element with your snippet (there is an RFE on file for 
that).

I’d like to recommend that you try going through the following tutorial, which 
gives you a hands-on tour of the Search API, including how to set up 
constraints and use some of the other basic features.  
http://developer.marklogic.com/howto/tutorials/2009-07-search-api-walkthrough.xqy

I hope this helps!

Regards,

--Colleen Whitney

From: [email protected] 
[mailto:[email protected]] On Behalf Of Joshil Avikkal
Sent: Thursday, August 06, 2009 7:55 AM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] pagination using new search API

Hi,

I have an xml like follows and my database contains just one document with 
similar tags.

<Root>
<title>cook1
<Category count =”1” >wine and beer, wine and water </category
<Category count =”2” >this is a sample document </category>
</title>
<title>cook2
<Category count =”1” >party and cocktail</category>
<2title>
<title>cook3
<Category count =”1” >wine</category>
</title>
</root>

I would like to use “search: search” function and get following the string term 
“wine”.    .

1.  Total number of the matches found in number of <title> tags.
     In this example, although the “wine” appears twice in the <title> “Cook1”, 
it should be counted as 1 and it should return only two search:result nodes. I 
set <max-matches> to 1 control this.
     But I need to find out how many such matches exist in entire document.  Is 
there way to find this out without traversing through the entire search:result ?

2.  Along with the search:snippet   I always want to display the  value of the 
<title> tag  inside with search:result along with search:snippet.  How can I do 
this ?


Thank you,
--Joshil

---------------------------------------------------------------------------------------------



This message, including any attachments, contains confidential information 
intended for a specific individual and purpose, and is intended for the 
addressee only. Any unauthorized disclosure, use, dissemination, copying, or 
distribution of this message or any of its attachments or the information 
contained in this e-mail, or the taking of any action based on it, is strictly 
prohibited. If you are not the intended recipient, please notify the sender 
immediately by return e-mail and delete this message.



---------------------------------------------------------------------------------------------


_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to