Ambika Use the grammar below and modify it according to your requirement . Just add the grammar to your search option
<grammar xmlns="http://marklogic.com/appservices/search"> <quotation>"</quotation> <implicit> <cts:and-query strength="20" xmlns:cts=" http://marklogic.com/cts"/> </implicit> <starter strength="30" apply="grouping" delimiter=")">(</starter> <starter strength="40" apply="prefix" element="cts:not-query">-</ starter> <joiner strength="10" apply="infix" element="cts:or-query" tokenize=" word">OR</joiner> <joiner strength="20" apply="infix" element="cts:and-query" tokenize="word">AND</joiner> <joiner strength="30" apply="infix" element="cts:near-query" tokenize="word">NEAR</joiner> <joiner strength="30" apply="near2" element="cts:near-query">NEAR/</ joiner> <joiner strength="50" apply="constraint">:</joiner> <joiner strength="50" apply="constraint" compare="LT" tokenize="word ">LT</joiner> <joiner strength="50" apply="constraint" compare="LE" tokenize="word ">LE</joiner> <joiner strength="50" apply="constraint" compare="GT" tokenize="word ">GT</joiner> <joiner strength="50" apply="constraint" compare="GE" tokenize="word ">GE</joiner> <joiner strength="50" apply="constraint" compare="NE" tokenize="word ">NE</joiner> </grammar> Regards Abhishek Srivastav Assistant Systems Engineer Tata Consultancy Services Plot B-1, Block EP & GP, Sector 5 Salt Lake Electronics Complex, Kolkata - 700 091,West Bengal India Cell:- +91-9883389968 Mailto: abhishek5...@tcs.com Website: http://www.tcs.com ____________________________________________ Experience certainty. IT Services Business Solutions Outsourcing ____________________________________________ From: ambika arumugam <ambikaarumuga...@gmail.com> To: General MarkLogic Developer Discussion <general@developer.marklogic.com> Date: 05/03/2011 06:08 PM Subject: Re: [MarkLogic Dev General] Reg: Advanced search query formation Sent by: general-boun...@developer.marklogic.com Hi Abhishek , I understand the use of search:parse but can you tell me how to overwrite the default grammer ( using joiner, starter in implicit ) On Mon, May 2, 2011 at 2:07 PM, Abhishek53 S <abhishek5...@tcs.com> wrote: Hi Ambika I guess you no need to create any cts query (cts:and-query , cts:or-query, cts:not-query) from query text. You can do it either way Use the search:parse API and override the Marklogic existing grammar accordingly. Pass the queryXML (search:parse() output) to the search:resolve API. Use the search:search API and directly pass the query text as input. In both the scenario you just need to create the constraint over the specific field. Thanks & Regards Abhishek Srivastav Assistant Systems Engineer Tata Consultancy Services Plot B-1, Block EP & GP, Sector 5 Salt Lake Electronics Complex, Kolkata - 700 091,West Bengal India Cell:- +91-9883389968 Mailto: abhishek5...@tcs.com Website: http://www.tcs.com ____________________________________________ Experience certainty. IT Services Business Solutions Outsourcing ____________________________________________ From: ambika arumugam <ambikaarumuga...@gmail.com> To: General MarkLogic Developer Discussion <general@developer.marklogic.com> Date: 05/02/2011 01:37 PM Subject: [MarkLogic Dev General] Reg: Advanced search query formation Sent by: general-boun...@developer.marklogic.com Hi all, I am working with an advanced search functionality in which i have to search against anyfield in a xml and the input for it is 'AnyField:"test" AND AnyField:"test2" OR Anyfield:"test3" NOT AnyField:"test4"'. I would like to get the results in a such a way that, should return the documents which has element values "test" and "test2" may be "test3" and should not contain "test4". >From my understanding i can use word-query with cts:and-query,cts:or-query and cts:not-query combination's. But i would like to know how to split the input string to form the query for different and,or and not combinations.There can be any number AnyField: combinations as an input. Please suggest how to get this done. Thanks in advance, Ambika_______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you
_______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general