Hi Gurbeer, Assuming you mean you are doing an AND query of all of the terms in your search string, I think if you want to not highlight your stop words, you would be better off changing your cts:query ($query in your snippet) and removing the cts:word-query for each stop word.
Here is an example of what I am talking about: xquery version '1.0-ml'; import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy"; let $stop := ("or", "and", "of") let $qtext := "code of conduct" let $query := search:parse($qtext) let $qtext2 := for $x in fn:tokenize($qtext, " ") return ( if ($x = $stop) then () else $x ) let $query2 := search:parse($qtext2) let $doc := <foo> hello this is a code and the word of and some conduct</foo> return ( cts:highlight($doc, cts:query($query), <highlight>{$cts:text}</highlight>), cts:highlight($doc, cts:query($query2), <highlight>{$cts:text}</highlight>), $qtext2 ) => <foo> hello this is a <highlight>code</highlight> and the word <highlight>of</highlight> and some <highlight>conduct</highlight></foo> <foo> hello this is a <highlight>code</highlight> and the word of and some <highlight>conduct</highlight></foo> code conduct -Danny From: [email protected] [mailto:[email protected]] On Behalf Of Singh, Gurbeer Sent: Friday, June 24, 2011 2:02 PM To: General MarkLogic Developer Discussion Subject: [MarkLogic Dev General] stoppers in cts:highlight Hi, I have a new requirement . When I search for a term called "code of conduct", It gives me a result set. Now when I am calling cts:highlight to find out my highlight term, its highlighting "code of conduct" "code" "of" "conduct" which is true. But if a document contains lots of "of" it's not looking good. So we have identified list of stopper (a,an,the,of,at,on,and,or) and don't want to highlight them. I am trying like this but it's not working cts:highlight($doc, $query, if (cts:word-query-text($cts:queries) eq "of") then {fn:string-join($cts:text," ")} else <search:highlight>{fn:string-join($cts:text," ")}</search:highlight> ) ~Gurbeer ________________________________________ NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers. If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing. _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
