Hi, Asit:

The path index specifies which element or attribute is indexed rather than 
which values of an element or attribute are indexed.

You might be able to filter the lexicon values using the start-facet / 
finish-facet functions of a custom constraint:

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

However, the approach will be more maintainable and better performing long term 
if you treat this as a data integrity or data cleansing issue:  either reject 
documents without a valid author element or, after ingestion, remove invalid 
author elements, preserving the text.  In other words, ensure that the author 
element contains only valid authors to ensure that the range index contains 
only valid authors.


Hoping that's helpful,


Erik Hennum

________________________________
From: [email protected] 
[[email protected]] on behalf of 
[email protected] [[email protected]]
Sent: Wednesday, August 21, 2013 12:55 AM
To: [email protected]
Subject: [MarkLogic Dev General] Remove Null facet-values from search-result in 
MarkLogic 6 REST-API's


Hi ,

I am using MarkLogic 6.0 Rest Api’s to search content and I have an query about 
facets.


I am getting by default facet for an element like “author” as below in my 
search result from content:

<search:facet name="author" type="xs:string">
 <search:facet-value name="" count="87462"/>
 <search:facet-value name=" " count="287"></search:facet-value>
 <search:facet-value name=" " count="7892"></search:facet-value>
 <search:facet-value name=" Marino" count="1">Marino</search:facet-value>
  <search:facet-value name="<i>from</i> ABC News" count="7"><i>from</i> ABC 
News</search:facet-value>
</search:facet>

In above result , I am getting facet-value for those author elements which  
values are null, single or more space, new line null values and text values as 
by default behavior of REST API’s.

As per my requirement, I don’t want those null, single or more space and new 
line null values, I want only those facet-values which contains only text value 
as below.

<search:facet name="author" type="xs:string">
 <search:facet-value name=" Marino" count="1">Marino</search:facet-value>
  <search:facet-value name="<i>from</i> ABC News" count="7"><i>from</i> ABC 
News</search:facet-value>
</search:facet>


I created following constraint in search option file and created range path 
index (*:author[. ne ""][. ne " "]) in MarkLogic also.

<search:constraint name="author">
    <search:range 
collation="http://marklogic.com/collation//S2<http://marklogic.com/collation/S2>"
 type="xs:string" facet="true">
      <search:facet-option>ascending</search:facet-option>
      <search:facet-option>limit=10</search:facet-option>
                   <search:path-index>*:author[. ne ""][. ne " 
"]</search:path-index>
    </search:range>
  </search:constraint>

But I am able to remove only facet-value for author’s element null values. I 
need to also remove facet values for single or more space and new line null 
values.
And we can’t use    *:author[fn:normalize-space(.) ne ""]  as path index.

Is there any solution to achieve this goal?

Regards,
Asit Nautiyal

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.
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to