[MarkLogic Dev General] Search Constraints in XQuery

Erik Hennum Erik.Hennum at marklogic.com
Fri Jan 22 11:07:21 PST 2016


Hi, Ravindra:

Have you tried search:parse()?  That returned the expected query in my testing.

Also, you can add <debug>true</debug> to your query options to see the query being executed by search:search().

If it works for search:parse() but not search:search(), that's a bug. What version are you on?


Erik Hennum

________________________________________
From: general-bounces at developer.marklogic.com [general-bounces at developer.marklogic.com] on behalf of Ravindra B Mamidipaka [ravi_b_m at hotmail.com]
Sent: Friday, January 22, 2016 9:19 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Search Constraints in XQuery

Hello Erik,
  Thank you for the suggestion eric, but that does not seems to work.. I get the following exception
[1.0-ml] XDMP-AS: (err:XPTY0004) $container-elem as element() -- Invalid coercion: () as element()

The workaround for now I did is created a field for the nested properties and have a range index.. This seems to be working but I want a generic enough solution as , I have 90 nested fields with different hierarchies and I do not want to create fields for each hierarchy..


Thanks,
Ravi

Hello Charles,
  Thank you for your suggestions but when I try that way.. It does not work..

Thanks
Ravi

________________________________
> From: Erik.Hennum at marklogic.com
> To: general at developer.marklogic.com
> Date: Thu, 21 Jan 2016 19:28:23 +0000
> Subject: Re: [MarkLogic Dev General] Search Constraints in XQuery
>
> Hi, Ravindra:
>
> It should work if you prefix the container before the contained
> constraint, as in:
>
> let $search := "concept.registrar:username:WHITEMK"
>
> By the way, when you're trying to understand how a query text is being
> parsed,
> it's sometimes easier to work with search:parse() at first.
>
>
> Hoping that helps,
>
>
> Erik Hennum
>
> ________________________________
> From: general-bounces at developer.marklogic.com
> [general-bounces at developer.marklogic.com] on behalf of Ravindra B
> Mamidipaka [ravi_b_m at hotmail.com]
> Sent: Wednesday, January 20, 2016 5:55 AM
> To: MarkLogic Developer Discussion
> Subject: Re: [MarkLogic Dev General] Search Constraints in XQuery
>
> Hello Charles,
> Thank you for the suggestions.. Is it possible to provide a container
> -query example for this case.. I am trying to wrap my head around the
> concept and getting nowhere :).. Following is what I tried, and it does
> not work
>
> let $search := "(username:WHITEMK) AND (concept.registrar: )"
>
> let $options :=
> <options xmlns="http://marklogic.com/appservices/search">
> <constraint name="concept.registrar">
> <container>
> <json-property>registrar</json-property>
> </container>
> </constraint>
> <constraint name="username">
> <value>
> <json-property>username</json-property>
> <term-option>case-insensitive</term-option>
> <term-option>wildcarded</term-option>
> </value>
> </constraint>
> <return-facets>false</return-facets>
> <return-values>false</return-values>
> <return-constraints>false</return-constraints>
> <return-frequencies>false</return-frequencies>
> <return-qtext>false</return-qtext>
> <search-option>unfiltered</search-option>
> <search-option>unfaceted</search-option>
> <search-option>format-json</search-option>
> <search-option>score-simple</search-option>
> </options>
>
> let $start := 1
> let $page-length :=10000
>
> return search:search($search, $options, $start, $page-length)
>
> Thanks,
> Ravi
>
>
>
> ________________________________
> From: Charles.Greer at marklogic.com
> To: general at developer.marklogic.com
> Date: Wed, 20 Jan 2016 04:04:06 +0000
> Subject: Re: [MarkLogic Dev General] Search Constraints in XQuery
>
> Hello Ravi,
>
> Your guess is correct -- json-property can not be used for nested elements.
>
> You can add additional query terms to limit the search to 'registrar',
> like a container-query
> (that would be a runtime additional query to AND with the bare json-property)
>
> or if you can use a path range index (wouldn't be for matches and
> wildcards though),
> a path range index with path definition registrar/username would match
> the location you have.
>
> Not sure how helpful this response is though..
>
> Charles
>
>
> ________________________________
> From: general-bounces at developer.marklogic.com
> [general-bounces at developer.marklogic.com] on behalf of Ravindra B
> Mamidipaka [ravi_b_m at hotmail.com]
> Sent: Tuesday, January 19, 2016 12:54 PM
> To: general at developer.marklogic.com
> Subject: [MarkLogic Dev General] Search Constraints in XQuery
>
>
> In the search:search in XQuery.. for search constraints , how do I
> specify the json-property to be nested ? I am trying this and it does
> not work
>
> <options
> xmlns="http://marklogic.com/appservic...<http://marklogic.com/appservices/search>">
> <constraint name="concept.registrar.username">
> <value>
> <json-property>registrar/username</json-property>
> <term-option>case-insensitive</term-option>
> <term-option& gt;wildc arded</term-option>
> </value>
> </constraint>
> </options>
>
>
>
> Thanks,
>
> Ravi
>
>
>
> _______________________________________________ General mailing list
> General at developer.marklogic.com Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
> _______________________________________________ General mailing list
> General at developer.marklogic.com Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
General at developer.marklogic.com
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general


More information about the General mailing list