Hi, Pragya: I'm not sure moving the comparison into the where clause will help a lot.
It might help a little to set a variable to $searchResult//title/text() once and then test that multiple times. Far better would be to process as many of the variants as possible with indexes in the query. For instance, would it be possible to do contains as a word query and exact match as a value query? Erik Hennum ________________________________ From: [email protected] [[email protected]] on behalf of Pragya Kapoor [[email protected]] Sent: Friday, August 30, 2013 2:22 AM To: [email protected] Subject: [MarkLogic Dev General] conditonal expression in where clause Hi If it possible to put a condition (if else) in where clause? If yes how? For example I want to do : Let $term := ‘IBM’ let $searchResults := for $searchResult in cts:search(/books/book/chapter, $query,'unfiltered') let $tempResult:= if ($type eq $CONTAINS) then if (fn:contains($searchResult//title/text(), $term,$COLLATION) eq fn:true())then $searchResult else () else if ($type eq $STARTS_WITH) then if (fn:starts-with($searchResult//title/text(), $term,$COLLATION) eq fn:true()) then $searchResult else () else if ($type eq $ENDS_WITH) then if (fn:ends-with($searchResult//title/text(), $term, $COLLATION) eq fn:true()) then $searchResult else () else if ($type eq $EXACT_MATCH) then if (fn:compare($searchResult//title/text(), $term, $COLLATION) eq 0) then $searchResult else () else () return $tempResult Instead of iterating through each result, I want to put these conditions in where clause, so that performance would be better. Thanks Pragya **************** CAUTION - Disclaimer ***************** This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system. ***INFOSYS******** End of Disclaimer ********INFOSYS***
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
