cts:search only performs a single search so you won't get duplicate records 
from it.

Check your data. My guess would be that you've uploaded duplicate documents at 
separate URIs. I believe this likely to be true because you're using timestamps 
in your URIs.

Best,
Rob

Rob Szkutak
Senior Consultant
MarkLogic Corporation
[email protected]
www.marklogic.com<http://www.marklogic.com>

________________________________
From: [email protected] 
[[email protected]] on behalf of Kari Cowan 
[[email protected]]
Sent: Friday, March 04, 2016 5:36 PM
To: [email protected]
Subject: [MarkLogic Dev General] Need a suggestion for grouped search

I am using ML 7, and trying to do a grouped search.  In my test below, 
this_partner is 2 partners, split by the / character.  In the search, it would 
then search one, then the other.  I was hoping in the return, using 
fn:distinct-values(), I would only return the record if it had not already 
returned it.  In fact, it seemed to work that way in Qconsole but when I 
applied it to my query on the server, it would return a duplicate result for 
each record.

I am assuming what I am doing below is inadequate to get the result I am 
looking for, but the failure doesn’t produce an exception.

Any suggestion for what might be better?

I was going to try distinct-nodes instead but I don’t think that’s available in 
ML7, is that true?

xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";;

let $this_partner:="Benefits Pro/Life Health Pro"
let $this_partner:= fn:tokenize($this_partner,"/")

let $search-this-partner:=
cts:search(fn:doc(),cts:and-query((
  cts:element-value-query(xs:QName("almmediapartner"),$this_partner),
  cts:element-query(xs:QName("approval_status"),cts:word-query("true")),
cts:element-attribute-range-query(xs:QName("EventStartDate"), xs:QName("date"), 
">=", xs:date(fn:current-date()) )
)))


return if(fn:distinct-values($search-this-partner/event/doc-uri) ) then
   $search-this-partner/event/(EventTitle|doc-uri)
   else ()

Results in Qconsole >>

<EventTitle>Test Record Title</EventTitle>
<doc-uri>/data-sources/events/BenefitsandLifeHealthPartners:2016-03-04-05:00:58.xml</doc-uri>

Results from server online >>

Test Record Title
Test Record Title



________________________________
Learn more about ALM, visit http://www.alm.com . – ALM, an Integrated Media 
Company, is a leading provider of news and information for the legal and 
commercial real estate markets. ALM’s market-leading brands include The 
American Lawyer, Corporate Counsel, GlobeSt.com, Insight Conferences, Law.com, 
Law Journal Press, LegalTech, The National Law Journal and Real Estate Forum.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to