Hi Kelly, You are right. I was using Search API earlier, but we got some specific requirement with search relevancy rule in our Application.
In which we have to give high priority to some case E.g If title contains exact search term -->110% If title is exact search term -->100% If [some element1] contains exact search term -->90% If [some element2] contains exact search term -->85% Now look into entire Database for exact search term -->80% Now look into entire Database for search term -->75% (here I need dynamic OR query) If there is a tie, then we have a tie breaker on content type I am building my query accordingly and using search:resolve I will use suggestion for last case and this is working fine, Thanks. Kelly if possible please comment in my approach . If u see anything wrong I am doing. I tried using Database Word Query configuration including some element with weight. But that made be confused because score was different. ~Gurbeer -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Kelly Stirman Sent: Friday, June 24, 2011 10:50 AM To: [email protected] Subject: Re: [MarkLogic Dev General] dynamic cts OR Query Hi Gurbeer, Have you looked at using the SearchAPI for this? Parsing the user's query string can get to be pretty messy, and the SearchAPI handles this well. Specific to your question, I think you can use the following: cts:or-query(( cts:word-query((fn:tokenize($searchterm," ")), "case-insensitive"), cts:word-query($searchterm, "case-insensitive") )) But I wouldn't use fn:tokenize, I would use cts:tokenize so that the tokenization rules match what the indexer is using. That is only one of the tricky things you run into when trying to parse a user query string. :) Kelly Message: 3 Date: Fri, 24 Jun 2011 10:34:27 -0400 From: "Singh, Gurbeer" <[email protected]> Subject: [MarkLogic Dev General] dynamic cts OR Query To: <[email protected]> Message-ID: <0a864c62635cd34480d56e4f206d148cad90e75...@nywexmbx2123.msad.ms.com> Content-Type: text/plain; charset="us-ascii" Hi, I need to build a dynamic OR query Let's say my search term is "code of conduct" so output should be <cts:or-query> <cts:word-query> <cts:text>Code</cts:text> <cts:option>case-insensitive</cts:option> <cts:option>wildcarded</cts:option> </cts:word-query> <cts:word-query> <cts:text>of</cts:text> <cts:option>case-insensitive</cts:option> <cts:option>wildcarded</cts:option> </cts:word-query> <cts:word-query> <cts:text>Conduct</cts:text> <cts:option>case-insensitive</cts:option> <cts:option>wildcarded</cts:option> </cts:word-query> <cts:word-query> <cts:text xml:lang="en">code of conduct</cts:text> <cts:option>case-insensitive</cts:option> </cts:word-query> </cts:or-query> When I trying let $searchterm := "code of conduct" let $query :=cts:or-query((cts:word-query(fn:string-join($searchterm," "), "case-insensitive"), cts:word-query($searchterm, "case-insensitive"))) return $query <cts:or-query> <cts:word-query> <cts:text xml:lang="en">code of conduct</cts:text> <cts:option>case-insensitive</cts:option> </cts:word-query> <cts:word-query> <cts:text xml:lang="en">code of conduct</cts:text> <cts:option>case-insensitive</cts:option> </cts:word-query> </cts:or-query> I understand we should tokenize with " "and build the query, but we can't update variables in XQUERY right, that's why was wondering how to reach the solution ~Gurbeer _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general -------------------------------------------------------------------------- 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
