Re: [MarkLogic Dev General] cts:element-values() issue

2016-08-16 Thread Yalaverthi, Sudheer (LNG-RDU)
I have multiple grade elements. Ignore this thread.

From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Rob Szkutak
Sent: Tuesday, August 16, 2016 3:47 PM
To: MarkLogic Developer Discussion 
Subject: Re: [MarkLogic Dev General] cts:element-values() issue

Hello,

Do you have multiple  elements in some of your documents? That could 
explain why you're seeing more results beyond A, B and C.

If you can't filter your results from element-values correctly, another way to 
filter those out of your result set may be to add a "where" before your return:

where $grade eq 'A' or $grade eq 'B' or $grade eq 'C'

Best,
Rob

Rob Szkutak
Senior Consultant
MarkLogic Corporation
rob.szku...@marklogic.com<mailto:rob.szku...@marklogic.com>
www.marklogic.com<http://www.marklogic.com>


From: 
general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>
 [general-boun...@developer.marklogic.com] on behalf of Yalaverthi, Sudheer 
(LNG-RDU) [sudheer.yalaver...@lexisnexis.com]
Sent: Tuesday, August 16, 2016 2:33 PM
To: general@developer.marklogic.com<mailto:general@developer.marklogic.com>
Subject: [MarkLogic Dev General] cts:element-values() issue
Hi,


I have some data with the below format.


Mark
A
2016


I need to find out in between 2011 to 2016, how many students got grade A, how 
many got grade B, how many got grade C.

I initially wrote a query like this.


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

for $grade in
cts:element-values(
  xs:QName('grade'),
  (),
  ("frequency-order"),
  cts:and-query((
cts:element-range-query(xs:QName('year'), '>=', xs:int(2011)),
cts:element-range-query(xs:QName('year'), '<=', xs:int(2016)),
cts:element-range-query(xs:QName('grade'), '=', ('A', 'B', 'C'))
  ))
)
 return concat("grade :", $grade, " students with this grade :" , 
cts:frequency($grade))




I was expecting only grade A, B and C in the output but to my surprise, I am 
getting other grades as well like D, E, F and so on.

What am I missing here and is there any efficient way to achieve this? I have 
around 160 million records.


-Sudheer
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] cts:element-values() issue

2016-08-16 Thread Rob Szkutak
Hello,

Do you have multiple  elements in some of your documents? That could 
explain why you're seeing more results beyond A, B and C.

If you can't filter your results from element-values correctly, another way to 
filter those out of your result set may be to add a "where" before your return:

where $grade eq 'A' or $grade eq 'B' or $grade eq 'C'

Best,
Rob

Rob Szkutak
Senior Consultant
MarkLogic Corporation
rob.szku...@marklogic.com
www.marklogic.com<http://www.marklogic.com>


From: general-boun...@developer.marklogic.com 
[general-boun...@developer.marklogic.com] on behalf of Yalaverthi, Sudheer 
(LNG-RDU) [sudheer.yalaver...@lexisnexis.com]
Sent: Tuesday, August 16, 2016 2:33 PM
To: general@developer.marklogic.com
Subject: [MarkLogic Dev General] cts:element-values() issue

Hi,


I have some data with the below format.


Mark
A
2016


I need to find out in between 2011 to 2016, how many students got grade A, how 
many got grade B, how many got grade C.

I initially wrote a query like this.


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

for $grade in
cts:element-values(
  xs:QName(‘grade’),
  (),
  (“frequency-order”),
  cts:and-query((
cts:element-range-query(xs:QName('year'), '>=', xs:int(2011)),
cts:element-range-query(xs:QName('year'), '<=', xs:int(2016)),
cts:element-range-query(xs:QName('grade'), '=', ('A', 'B', 'C'))
  ))
)
 return concat("grade :", $grade, " students with this grade :" , 
cts:frequency($grade))




I was expecting only grade A, B and C in the output but to my surprise, I am 
getting other grades as well like D, E, F and so on.

What am I missing here and is there any efficient way to achieve this? I have 
around 160 million records.


-Sudheer
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] cts:element-values() issue

2016-08-16 Thread Yalaverthi, Sudheer (LNG-RDU)
Hi,


I have some data with the below format.


Mark
A
2016


I need to find out in between 2011 to 2016, how many students got grade A, how 
many got grade B, how many got grade C.

I initially wrote a query like this.


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

for $grade in
cts:element-values(
  xs:QName('grade'),
  (),
  ("frequency-order"),
  cts:and-query((
cts:element-range-query(xs:QName('year'), '>=', xs:int(2011)),
cts:element-range-query(xs:QName('year'), '<=', xs:int(2016)),
cts:element-range-query(xs:QName('grade'), '=', ('A', 'B', 'C'))
  ))
)
 return concat("grade :", $grade, " students with this grade :" , 
cts:frequency($grade))




I was expecting only grade A, B and C in the output but to my surprise, I am 
getting other grades as well like D, E, F and so on.

What am I missing here and is there any efficient way to achieve this? I have 
around 160 million records.


-Sudheer
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general