[MarkLogic Dev General] Facets on properties in ML4.2

Geert Josten Geert.Josten at marklogic.com
Fri Jan 8 05:33:05 PST 2016


Hi Raja,

Properties are saved as XML, so you can use an ordinary element range index to get those indexed. It will index both document fragments and properties fragments. I highly recommend adding these indexes, otherwise your facets will be very slow, and implementation will be a challenge.

If the code is calling search:search directly, see docs on how parse and parse-structured differ, and follow that accordingly. In the end they both return the same, just a slightly different starting point.

Consider writing a library to do the ‘heavy' lifting, and then make 10 thin xqy modules, that use that library but each pass in a different QName to use the correct index.

Alternatively, you could annotate your custom constraint with the appropriate QName of the property, and see if you can pull up the annotation from within the code. That way you only need one module that you reuse for each property facet, but configure for a different property.

All in all not ideal, but doable..

Kind regards,
Geert

From: <general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com>> on behalf of "Rajamani.Marimuthu at cognizant.com<mailto:Rajamani.Marimuthu at cognizant.com>" <Rajamani.Marimuthu at cognizant.com<mailto:Rajamani.Marimuthu at cognizant.com>>
Reply-To: MarkLogic Developer Discussion <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Date: Friday, January 8, 2016 at 1:51 PM
To: "general at developer.marklogic.com<mailto:general at developer.marklogic.com>" <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Subject: Re: [MarkLogic Dev General] Facets on properties in ML4.2

Hi Geert,

It’s really a helpful information .But , in my case lot of restrictions are there .


1.       The search:search function directly called in XQuery code[ not by REST api] with all search criteria mentioned in advanced Query part of  options section

Like search:search(“”,$options,$start,$count)

2.       Property elements are not range indexed – especially needed for facets .

3.       But, no other alternative options available like fragment-scope kind of things in ML4.2.

Need to implement totally 10 faceted elements . If custom constrain is the only option then – need to write lot of extra code to achieve the requirement .  So, based on above limitations ,still is it possible to achieve my clients requirement Kindly suggest .


By
Raja >>>

From: general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com> [mailto:general-bounces at developer.marklogic.com] On Behalf Of Geert Josten
Sent: Friday, January 08, 2016 6:03 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Facets on properties in ML4.2

Hi Raja,

The parse/parse-structured are called when you have a search string that contains a prefix that refers to your custom constraint. So if you have a constraint name ’foo’, and you search for “foo:bar”, parse is used to convert foo:bar into an actual query to constrain search results. Whether the library will call parse or parse-structured, that depends on how you use the search library. REST api always triggers parse-structured, a direct call to search:search triggers parse if I am not mistaken. If you are using REST api, you shouldn’t need the parse, just refer to parse-structured.

Start-facet is executed in parallel if I am not mistaken, so it should run across the cluster. The finish-facet gathers the results, and just converts the results from lexicon lookups into xml that is included in the search response. The example from the docs already includes a finish-facet, and I thought you don’t need to change it, or maybe only limited.

Kind regards,
Geert

From: <general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com>> on behalf of "Rajamani.Marimuthu at cognizant.com<mailto:Rajamani.Marimuthu at cognizant.com>" <Rajamani.Marimuthu at cognizant.com<mailto:Rajamani.Marimuthu at cognizant.com>>
Reply-To: MarkLogic Developer Discussion <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Date: Friday, January 8, 2016 at 1:19 PM
To: "general at developer.marklogic.com<mailto:general at developer.marklogic.com>" <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Subject: Re: [MarkLogic Dev General] Facets on properties in ML4.2

Hi Geert ,

Thanks for the quick reply , what about the parse and finish-facet parts . Am really confused about this custom constraints . If possible kindly give me some sample code for properties.

By
Raja >>>

From:general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com> [mailto:general-bounces at developer.marklogic.com] On Behalf Of Geert Josten
Sent: Friday, January 08, 2016 5:30 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Facets on properties in ML4.2

Hi Raja,

Yes, I think so, provided custom constraints were supported in that version. Here an example:

http://docs.marklogic.com/guide/search-dev/search-api#id_66428

It makes uses of geospatial lexicon ‘values’ (boxes), but just replace cts:element-pair-geospatial-boxes in start-facet with cts:element-values (with a properties options), and you should be pretty close to what you are looking for. Then for the actual searching, you need to change parse-structured to return a cts:element-range-query..

Kind regards,
Geert

From: <general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com>> on behalf of "Rajamani.Marimuthu at cognizant.com<mailto:Rajamani.Marimuthu at cognizant.com>" <Rajamani.Marimuthu at cognizant.com<mailto:Rajamani.Marimuthu at cognizant.com>>
Reply-To: MarkLogic Developer Discussion <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Date: Friday, January 8, 2016 at 12:50 PM
To: "general at developer.marklogic.com<mailto:general at developer.marklogic.com>" <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Subject: Re: [MarkLogic Dev General] Facets on properties in ML4.2

Hi Geert,

Am aware about that fragment-scope option in search constraints ,but it’s available from ML 5 onwards . So, no luck from that. Is that possible to use custom constraint to achieve my requirement .

By
Raja >>>

From:general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com> [mailto:general-bounces at developer.marklogic.com] On Behalf Of Geert Josten
Sent: Friday, January 08, 2016 3:29 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Facets on properties in ML4.2

Hi Raja,

If I am not mistaken, ML 4.2 supports the search API, with functions like search:search and such. You can define search constraints in your search options, and provide a fragment-scope in them. You can provide that on top-level, like shown here: http://docs.marklogic.com/guide/search-dev/appendixa#id_92359, but also within constraints, either directly below the constraint element, or within the range element.

I am not sure whether fragment-scope was supported in the early version of Search API in 4.2 as it was still pretty new back then, but that is how you would do it with MarkLogic 8.

Kind regards,
Geert

From: <general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com>> on behalf of "Rajamani.Marimuthu at cognizant.com<mailto:Rajamani.Marimuthu at cognizant.com>" <Rajamani.Marimuthu at cognizant.com<mailto:Rajamani.Marimuthu at cognizant.com>>
Reply-To: MarkLogic Developer Discussion <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Date: Friday, January 8, 2016 at 9:32 AM
To: "general at developer.marklogic.com<mailto:general at developer.marklogic.com>" <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Subject: Re: [MarkLogic Dev General] Facets on properties in ML4.2

Hi Justin,

  Thanks for the reply mail . Yes we are using ML4.2 version but, we are preparing the migration from 4.2 to latest 8.* version very soon.
   But, right now – we don’t have any document content change plan- so I need to implement the expected facet on properties files. Am really clueless about this custom constraint on properties for facets.
  So, are you saying – value constraint can help to create facets on properties . Here “envelop original content and properties” meant – am I want to save both in single XML file. Could you please give little more points about this implementation .

Or if that is not possible with existing content and properties in ML4.2 then what is the alternative method for the same . Kindly appreciate your timely support .

By
Raja >>>

From:general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com> [mailto:general-bounces at developer.marklogic.com] On Behalf Of Justin Makeig
Sent: Thursday, January 07, 2016 11:20 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Facets on properties in ML4.2

Are you really running MarkLogic 4.2? This is ancient. You should plan to upgrade as soon as feasible. It will be very difficult for the community or MarkLogic Support to assist you with this version. The most recent version is 8.0-4.

It is possible to facet on properties. cts:values has an option that allows you include values from properties fragments. (Or cts:element-values in 4.2.) However, in general, I'd advise against properties fragments. Because they are separate from document fragments, properties require extra work to join at query time. If you don't want to change/enrich your actual document content you can use an envelope to "wrap" your documents:

<my:envelope xmlns:my="…">
  <my:meta>…</my:meta><!-- <-- properties go here -->
  <my:body>…</my:body><!-- <-- organically document contents goes here -->
</my:envelope>

This has the advantage of segregating the metadata (properties) and data, but also colocates them in the same fragment, reducing the work that queries will have to do.

Justin


On Jan 7, 2016, at 1:35 AM, Rajamani.Marimuthu at cognizant.com<mailto:Rajamani.Marimuthu at cognizant.com> wrote:

Hi Team,

  We are trying to implement facets from various property elements in ML4.2 version . Is that possible. Like

  Search term :  “sample” present in content body
  Facets : on some properties like : author, geography   etc. from document properties . Kindly appreciate if have some sample custom constraint or similar options

By
Raja >>>
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored.
_______________________________________________
General mailing list
General at developer.marklogic.com<mailto:General at developer.marklogic.com>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general

This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored.
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored.
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored.
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20160108/b280f81b/attachment-0001.html 


More information about the General mailing list