Hi Geert, I came across element-constraint-query from the following link
http://docs.marklogic.com/guide/search-dev/structured-query#id_64263 which i thought would suit my requirement to limit the search to Lab/Description. However the constraint mentioned by you behaves as a simple element-word-query. Please find the output of search:parse <cts:element-word-query qtextpre="LabDescription:" qtextref="cts:annotation" xmlns:cts="http://marklogic.com/cts"> <cts:element>Description</cts:element> <cts:annotation qtextpre=""" qtextref="following-sibling::cts:text" qtextpost="""/> <cts:text>Machine engineering</cts:text> <cts:option>wildcarded</cts:option> <cts:option>case-insensitive</cts:option> <cts:option>diacritic-insensitive</cts:option> <cts:option>unstemmed</cts:option> </cts:element-word-query> This constraint searches <Description> present not only in <Lab> but also in <Workshop>. But I want the search to be restricted to Lab/Description. Regards, Blessing. On Tue, Dec 10, 2013 at 5:07 PM, Geert Josten <[email protected]> wrote: > Hi Blessing, > > That is probably because there is no such thing as an > element-constraint-query. You could use this instead: > > <constraint name="LabDescription"> > <word type="xs:string" facet="false"> > <element ns="" name="Description" /> > {$QUERY-OPTIONS} > </word> > </constraint> > > Examples and explanation can be found here: > http://docs.marklogic.com/search:search#opt-constraint > > And when in doubt, you could use this to validate your search options: > http://docs.marklogic.com/search:check-options > > Kind regards, > Geert > >> -----Oorspronkelijk bericht----- >> Van: [email protected] [mailto:general- >> [email protected]] Namens Blessing N >> Verzonden: dinsdag 10 december 2013 12:08 >> Aan: MarkLogic Developer Discussion >> Onderwerp: Re: [MarkLogic Dev General] Need help in element-constraint- >> query >> >> Hi Geert, >> >> Thanks for your reply. As suggested I replaced the braces with double > quotes >> >> LabDescription:"Machine engineering" >> >> Please find the output of search:parse >> >> <?xml version="1.0" encoding="UTF-8"?> >> <cts:word-query qtextpre="LabDescription:"" qtextref="cts:text" >> qtextpost=""" xmlns:cts="http://marklogic.com/cts"> >> <cts:text>Machine engineering</cts:text> >> </cts:word-query> >> >> It forms a simple word query without applying the >> element-constraint-query and returns all records which is not my >> requirement. >> >> Regards, >> Blessing >> >> On Tue, Dec 10, 2013 at 4:04 PM, Geert Josten <[email protected]> >> wrote: >> > Hi Blessing, >> > >> > Using braces in your search expression doesn't work. Try: >> > >> > LabDescription:"Machine engineering" >> > >> > A bit technical, but if you would use search:parse on your search >> > expression, you would notice that it decomposes it not as you were >> > expecting.. >> > >> > Kind regards, >> > Geert >> > >> >> -----Oorspronkelijk bericht----- >> >> Van: [email protected] [mailto:general- >> >> [email protected]] Namens Blessing N >> >> Verzonden: dinsdag 10 december 2013 10:43 >> >> Aan: MarkLogic Developer Discussion >> >> Onderwerp: Re: [MarkLogic Dev General] Need help in > element-constraint- >> >> query >> >> >> >> Hi Geert, >> >> >> >> This the $QUERY-OPTIONS >> >> >> >> declare variable $QUERY-OPTIONS := >> >> (<search:term-option>wildcarded</search:term-option>, >> >> >> >> <search:term-option>case-insensitive</search:term-option>, >> >> >> >> <search:term-option>diacritic-insensitive</search:term-option>, >> >> >> >> <search:term-option>unstemmed</search:term-option> >> >> ); >> >> >> >> and the search statement is >> >> >> >> LabDescription:(Machine engineering) >> >> >> >> Regards, >> >> Blessing >> >> >> >> On Mon, Dec 9, 2013 at 8:39 PM, Geert Josten <[email protected]> >> >> wrote: >> >> > Hi Blessing, >> >> > >> >> > What is the value of your $QUERY-OPTIONS variable? And what search >> >> > statement are you executing? >> >> > >> >> > Kind regards, >> >> > Geert >> >> > >> >> >> -----Oorspronkelijk bericht----- >> >> >> Van: [email protected] [mailto:general- >> >> >> [email protected]] Namens Blessing N >> >> >> Verzonden: maandag 9 december 2013 13:11 >> >> >> Aan: MarkLogic Developer Discussion >> >> >> Onderwerp: [MarkLogic Dev General] Need help in > element-constraint- >> >> query >> >> >> >> >> >> Hi, >> >> >> >> >> >> I have records of following format stored in Marklogic 6.0-2.3 >> >> >> >> >> >> <Record id=1> >> >> >> <Lab> >> >> >> <Code>050</Code> >> >> >> <Description>Laboratory Works</Description> >> >> >> </Lab> >> >> >> <Lab> >> >> >> <Code>078</Code> >> >> >> <Description>Laboratory Control</Description> >> >> >> </Lab> >> >> >> <Workshop> >> >> >> <Code>069</Code> >> >> >> <Description>Machine engineering<Description> >> >> >> </Workshop> >> >> >> </Record> >> >> >> >> >> >> <Record id=2> >> >> >> <Lab> >> >> >> <Code>085</Code> >> >> >> <Description>Machine engineering</Description> >> >> >> </Lab> >> >> >> <Lab> >> >> >> <Code>078</Code> >> >> >> <Description>Laboratory Control</Description> >> >> >> </Lab> >> >> >> <Workshop> >> >> >> <Code>023</Code> >> >> >> <Description>Power Consumption<Description> >> >> >> </Workshop> >> >> >> </Record> >> >> >> >> >> >> My requirement is to provide a word query search using > search:search >> >> >> to find records whose Lab/Description is "Machine engineering". >> >> >> >> >> >> If I try to execute element-word-query on <Description> it returns >> >> >> both the records. Since the requirement is to fetch only records >> >> >> having "Machine engineering" under Lab/Description I tried > creating a >> >> >> element-constraint-query on <Lab> as follows >> >> >> >> >> >> <constraint name="Lab"> >> >> >> <element-query ns="" name="Lab" /> >> >> >> {$QUERY-OPTIONS} >> >> >> </constraint> >> >> >> >> >> >> <constraint name="LabDescription"> >> >> >> <element-constraint-query> >> >> >> <constraint-name>Lab</constraint-name> >> >> >> <word type="xs:string" facet="false"> >> >> >> <element ns="" name="Description" /> >> >> >> {$QUERY-OPTIONS} >> >> >> </word> >> >> >> </element-constraint-query> >> >> >> </constraint> >> >> >> >> >> >> But it returned NIL results. >> >> >> >> >> >> Can anyone explain what is wrong in my element-constraint-query? >> >> >> Also I cannot use a path-range-query since i have to perform word >> >> >> query and not a value query. >> >> >> >> >> >> Thanks, >> >> >> Blessing. >> >> >> _______________________________________________ >> >> >> General mailing list >> >> >> [email protected] >> >> >> http://developer.marklogic.com/mailman/listinfo/general >> >> > _______________________________________________ >> >> > General mailing list >> >> > [email protected] >> >> > http://developer.marklogic.com/mailman/listinfo/general >> >> _______________________________________________ >> >> General mailing list >> >> [email protected] >> >> http://developer.marklogic.com/mailman/listinfo/general >> > _______________________________________________ >> > General mailing list >> > [email protected] >> > http://developer.marklogic.com/mailman/listinfo/general >> _______________________________________________ >> General mailing list >> [email protected] >> http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
