Re: [MarkLogic Dev General] Dynamic order by (message 4)

2015-05-06 Thread Kapoor, Pragya
Thanks a lot David for such a detail reply.


Are your element names from an infinate unknown set (i.e literally any name 
might be used),

or are they from a fixed set (>1) ? ​


The elements names are from an infinite unknown set. User can select any 
sorting element from the list(around 200 elements). Maximum elements that can 
be selected for sorting is 10.


So, I was looking for an approach with less overhead and is faster.


Thanks

Pragya


From: general-boun...@developer.marklogic.com 
 on behalf of David Lee 

Sent: Tuesday, May 5, 2015 10:26 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Dynamic order by (message 4)


' xdmp:eval and building the xquery order string through a function.'



xdmp:eval()  should be avoided if at all possible, especially with dynamically 
created string content its

incurs a significant overhead and opens the possibility of XQuery injection.

eval and invoke are intended for when you need contextual changes otherwise 
impossible (such as a new transaction,

running in a different module or DB etc).

*almost* anything else you can do with XQuery 3.x named and anonymous functions 
much easier, safer  and faster.



First consider that use of indexes and cts:search or search:search may 
implement what you want much better then XPath

and may not require an order-by depending on the range indexes.

search:search directly allows runtime sort order :



https://docs.marklogic.com/search:search



See:



Set the default sort order. The first such element is the primary sort order, 
the second secondary sort order, and so on. The default is to sort by score, 
descending. Note that the default scoring algorithm can be set just like any 
other option with the option named search-option. If you are sorting by an 
element or an attribute, you must specify a type attribute with a value 
corresponding to the range index type of that element or attribute (for 
example, xs:string, xs:dateTime, and so on). If the corresponding range index 
is of type xs:string, then you can optionally specify a collation attribute 
(otherwise the collation of the query is used). To change the sorting 
direction, specify an optional directionattribute with a value of decending 
(the default) or ascending.

The sort-order element must have one of a single element child, a single score 
child, a single field child, or a single json-property child. If there is a 
score child, it specifies to sort by the score of the search result. If there 
is an element child it can optionally have an attribute sibling (to specify an 
attribute of the preceding element). Both the element and attribute elements 
must have ns and name attributes to specify the namespace and local-name of the 
specified element and attribute. Additionally, the sort-order element can have 
0 or more annotation elements (to add comments, for example). You should not 
apply sort-order to a field backed by a field range index with more than one 
included element.

For example, the following specifies a primary sort order using the element 
value for my-element (which needs a string range index with the specified 
collation), and a secondary sort order of score ascending:

http://marklogic.com/collation/";

direction="ascending">

  

  some user comment can go here





  



The search library is very powerful and adopts 'best practice' over a large 
range of features.









If that doesnt work ...



Are your element names from an infinate unknown set (i.e literally any name 
might be used),

or are they from a fixed set (>1) ?

If its a compile time fixed set you can do some optimizations, including making 
range indexes over the

sort fields ...

--- Here are some examples to play with - not your exact structure, I used this 
code to generate 1 docs with 10 items of E{1...10} each



xdmp:document-delete(cts:uris());



declare variable $qn := ( 1 to 10 ) ! fn:QName( "" , "E" || . );



for $i in 1 to 1

return xdmp:document-insert( "/test."||$i||".xml" ,



   {

 for $item in 1 to 10

 return

{

  for $q in $qn return

   element {  $q} { xdmp:random(100) } ,

 The items value is: {$item}

}

}

)







   And here's a test program showing some different ways of doing 
things ---

Adding a range index to all the E* items helped a lot in some of the tests but 
not others.

This case I used a trick to simplify the ascending/descending case - the values 
are numeric so multiple by 1/-1

For text you may need to replicate the functions for ascending or descending or 
reverse the results afterwards.

In all these cases - performance will be improved dramatically if you can 
*first* filter the set of possible documents

before doing the sort -







declare variable $sort-name external := "E5" ;

declare variable $sort-elem external := element { xs:QName($sort-name)  } {}  ;

declare va

[MarkLogic Dev General] Using MarkLogic as SQL

2015-05-06 Thread SC-Khoo
Hi all,

Has anybody implemented MarkLogic like SQL to create BI reports? What's the
performance observed? 

 

I have converted 2 tables from my MS SQL server to MarkLogic.

The sample XML after converting to MarkLogic are:

1.   dbo.SCDetails



117311

9669

John.cashier



1023

42







ULTRASONIC THERAPY

Physiotherapy



1

3000.00

3000.00

0.00



 

2.   dbo. SCSBillRels



8073

6670

3449

11/19/2013 9:04:16 PM

Netty.Cashier-IPD





1



 

I have followed the instruction in
https://docs.marklogic.com/guide/sql/setup  to create the required element
range indexes and View for the 2 sets of XML above.

 

When I run the SQL query as shown below, I noticed that the performance
query from MarkLogic is too slow if compare to MS SQL. Is that normal???

Can anybody help to point out where I miss out or how to improve the
performance? 

Any help is appreciated!

 


SQL Query

MarkLogic 8 as SQL

(# records /time taken)

SQL


select  count(*) from main.dboscdetails

206817/4.259S

206817 (<0s)


select  count(*) from main.dboscsbillrels

250202/0.827S

250202 (<0s)


select  count(*) from main.dboscdetails SCDetails 

left join main.dboscsbillrels as SCSBillRels on SCSBillRels.SCDetailId =
SCDetails.Id

- (Query Console: Exceed Time Limit)

 

294585 (RazorSQL: 1641.403s)

294585 (<0s)

 

cheers,

SC-Khoo

 

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


[MarkLogic Dev General] Index inclusion rules for elements with and without attribute values

2015-05-06 Thread Will Thompson
I couldn't find an answer in the documentation regarding the specific case 
where conflicting rules are present for both an element without an attribute 
and for the same element with an attribute. So if a word index excludes root, 
includes , and excludes , should I expect 
cts:search(//doc, cts:word-query("*")) to return s with @include="false" 
or not? 

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


Re: [MarkLogic Dev General] JSON with namespace (XML to JSON - JSON to XML)

2015-05-06 Thread Paul Hoehne
You can use something called Clark notation, but that’s not a standard and is a 
convention wherein part of the name can be treated as a namespace.
{
“{http://my.namespace.com/some/uri}id”: 1234
}

http://www.jclark.com/xml/xmlns.htm

But if you need namespace support, it’s hard to beat XML.

Paul Hoehne
Senior Consultant
MarkLogic Corporation
paul.hoe...@marklogic.com
mobile: +1 571 830 4735
www.marklogic.com

Click http://po.st/hMGDFm to get your free NoSQL For Dummies e-book!

From: Justin Makeig 
mailto:justin.mak...@marklogic.com>>
Reply-To: MarkLogic Developer Discussion 
mailto:general@developer.marklogic.com>>
Date: Wednesday, May 6, 2015 at 12:32 PM
To: MarkLogic Developer Discussion 
mailto:general@developer.marklogic.com>>
Subject: Re: [MarkLogic Dev General] JSON with namespace (XML to JSON - JSON to 
XML)

No, for better or worse, JSON doesn't have the concept of namespaces as part of 
the data model like XML. You could capture the XML namespace as a property of 
the JSON document during transformation or use a naming convention for property 
names, e.g. "person$firstName". For namespaces that cover the entire document 
you might also consider a MarkLogic collection, for example,

http://example.org/ns/person";>Gnanaprakash

would map to

{ "firstName": "Gnanaprakash" } in the collection 
http://example.com/ns/person#Person, capturing the fully namespaced root 
element.

Justin



On May 5, 2015, at 6:12 AM, 
gnanaprakash.bodire...@cognizant.com
 wrote:

Hi

I am just wondering is there any way we have JSON documents with namespaces.

When an XML document is converted as JSON we lose the namespaces as JSON won’t 
carry namespace

and we try to covert JSON back to XML, the XML no longer carry the namespace as 
the source is JSON.

Is there any solution for this?

Regards,
Gnanaprakash Bodireddy




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@developer.marklogic.com
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general

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


Re: [MarkLogic Dev General] JSON with namespace (XML to JSON - JSON to XML)

2015-05-06 Thread Justin Makeig
No, for better or worse, JSON doesn't have the concept of namespaces as part of 
the data model like XML. You could capture the XML namespace as a property of 
the JSON document during transformation or use a naming convention for property 
names, e.g. "person$firstName". For namespaces that cover the entire document 
you might also consider a MarkLogic collection, for example,

http://example.org/ns/person 
">Gnanaprakash 

would map to 

{ "firstName": "Gnanaprakash" } in the collection 
http://example.com/ns/person#Person , 
capturing the fully namespaced root element.

Justin



> On May 5, 2015, at 6:12 AM, gnanaprakash.bodire...@cognizant.com wrote:
> 
> Hi
>  
> I am just wondering is there any way we have JSON documents with namespaces.
>  
> When an XML document is converted as JSON we lose the namespaces as JSON 
> won’t carry namespace
>  
> and we try to covert JSON back to XML, the XML no longer carry the namespace 
> as the source is JSON.
>  
> Is there any solution for this?
>  
> Regards,
> Gnanaprakash Bodireddy
> 
>  
>  
>  
> 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@developer.marklogic.com
> Manage your subscription at: 
> http://developer.marklogic.com/mailman/listinfo/general



smime.p7s
Description: S/MIME cryptographic signature
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] Calculating Node size

2015-05-06 Thread Brad Rix
You could always remove the namespaces before you perform the quote.This is 
a simple version for this example and you could write a recursive function if 
you have children nodes.

let $nodes-without-namespaces :=
 for $node in $nodes
 return
  element {fn:local-name($node)} {
 $node/@*,
 $node/text()
  }

let $quote :=xdmp:quote($nodes-without-namespaces)
let $string := for $i in $nodes-without-namespaces
return fn:string($i)
let $length:= for $i in $nodes-without-namespaces
return fn:string-length(fn:string($i))
…


Brad Rix | Technical Lead
O: +1 303 542 2172 | M: +1 303 915 2771
Skype: Brad.Rix | Google Talk: bradford@gmail.com

From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Jonna Marry
Sent: Wednesday, May 06, 2015 8:49 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Calculating Node size

Hi Mary,
We tried using fn:string. it will extract only the text node of each element. 
we need to include the number of character in element name. ie need to count 
Logging Ltd2. ignoring only namespace.
Query executed:
declare namespace info = "http://www.aaa-aaa.com/info";;
let $nodes := (Logging Ltd.1 ,
Logging Ltd2.,
Logging Ltd.3,
Logging Ltd4.
)
let $quote :=xdmp:quote($nodes)
let $string := for $i in $nodes
return fn:string($i)
let $length:= for $i in $nodes
return fn:string-length(fn:string($i))

return

{$quote}
{fn:string-length($quote)}
{$string}
{fn:sum($length)}


Output:

http://www.aaa-aaa.com/info";>Logging Ltd.1
http://www.aaa-aaa.com/info";>Logging 
Ltd2.
http://www.aaa-aaa.com/info";>Logging 
Ltd.3
http://www.aaa-aaa.com/info";>Logging 
Ltd4.351
Logging Ltd.1 Logging Ltd2. Logging Ltd.3 Logging Ltd4.
52

Regards,
Jonna

On Wed, May 6, 2015 at 8:52 AM, Mary Holstege 
mailto:mary.holst...@marklogic.com>> wrote:

Use fn:string instead of xdmp:quote
On May 6, 2015 5:32 AM, Jonna Marry 
mailto:nett77v...@gmail.com>> wrote:
Hi,
We need to calculate the character length of a Node. By applying xpath we are 
getting the sequence of nodes. We need to calculate the length of each node 
along with nodename and text values. Since we have same name space in all the 
element we want to ignore the namespace char length.
Is there any way to ignore namespaces only for size calculation.

For example:
let $nodes := (http://www.aaa-aaa.com/info";>Logging Ltd.1 ,
http://www.aaa-aaa.com/info";>Logging 
Ltd2.,
http://www.aaa-aaa.com/info";>Logging 
Ltd.3,
http://www.aaa-aaa.com/info";>Logging 
Ltd4.
)
For single node
Without namespace  size= 48
With namespace  size= 88
currently we are using fn:string-length( xdmp:quote($nodes[1])).
Regards,
Jonna

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

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


Re: [MarkLogic Dev General] Calculating Node size

2015-05-06 Thread Jonna Marry
Hi Mary,

We tried using fn:string. it will extract only the text node of each
element. we need to include the number of character in element name. ie
need to count *Logging Ltd2.* ignoring
only namespace.

*Query executed*:

declare namespace info = "http://www.aaa-aaa.com/info";;

let $nodes := (Logging Ltd.1 ,

Logging Ltd2.,

Logging Ltd.3,

Logging Ltd4.

)

let $quote :=xdmp:quote($nodes)

let $string := for $i in $nodes

return fn:string($i)

let $length:= for $i in $nodes

return fn:string-length(fn:string($i))



return



{$quote}

{fn:string-length($quote)}

{$string}

{fn:sum($length)}




*Output:*

http://www.aaa-aaa.com/info";>Logging Ltd.1
http://www.aaa-aaa.com/info";>Logging
Ltd2.
http://www.aaa-aaa.com/info";>Logging
Ltd.3
http://www.aaa-aaa.com/info";>Logging
Ltd4.351
Logging Ltd.1 Logging Ltd2. Logging Ltd.3 Logging Ltd4.
52


Regards,
Jonna

On Wed, May 6, 2015 at 8:52 AM, Mary Holstege 
wrote:

>  Use fn:string instead of xdmp:quote
> On May 6, 2015 5:32 AM, Jonna Marry  wrote:
> Hi,
>
>  We need to calculate the character length of a Node. By applying xpath we
> are getting the sequence of nodes. We need to calculate the length of each
> node along with nodename and text values. Since we have same name space in
> all the element we want to ignore the namespace char length.
>
>  Is there any way to ignore namespaces only for size calculation.
>
> For example:
>
>  let $nodes := (http://www.aaa-aaa.com/info";>Logging Ltd.1 ,
> http://www.aaa-aaa.com/info";>Logging
> Ltd2.,
> http://www.aaa-aaa.com/info";>Logging
> Ltd.3,
> http://www.aaa-aaa.com/info";>Logging
> Ltd4.
> )
>
>  For single node
>  Without namespace  size= 48
>  With namespace  size= 88
>
>  currently we are using fn:string-length( xdmp:quote($nodes[1])).
>
>  Regards,
>  Jonna
>
> ___
> General mailing list
> General@developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] Searching elements

2015-05-06 Thread Chad Bishop
Thank you all for your responses and help.

I’ll give those a try.

Thanks again,

-Chad

From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Indrajeet Verma
Sent: Wednesday, May 06, 2015 12:49 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Searching elements

Hi Chad Bishop,


You can try using cts:element-values() as well to get distinct subject values 
based on your input,

let $qtext := "whatever search"

let $terms :=  fn:tokenize($qtext," ")

let $q := cts:and-query((

cts:collection-query("content"),

cts:element-attribute-value-query(xs:QName("subj-group"), 
xs:QName("subj-group-type"),"heading"),

cts:element-word-query(xs:QName("subject"), $terms)

))

return cts:element-values(xs:QName("subject"), (), (), $q)

If you want exact subject values, use cts:element-value-query and 
case-insensitive option OR cts:element-range-query

Note - You would need to create range index for the subject to run above code.
[Inline image 1]

Regards,
Indy





On Wed, May 6, 2015 at 9:17 AM, Asitmohan Nautiyal 
mailto:asitmoha...@hcl.com>> wrote:
Hi Chad,

For searching a specific element and returning the matching values of that 
element use cts:element-value-query() function. Please refer 
https://docs.marklogic.com/cts:element-value-query

Avoid use  fn:distinct-values() function as its again a expensive in terms of 
performance. Use cts:values() function to get distinct terms from  a specified 
element. Refer https://docs.marklogic.com/cts:values

sample code is here :

cts:values(cts:path-reference("*:subject,"http://marklogic.com/collation//S2"),(),(),
cts:and-query((
cts:collection-query("content"),
cts:element-attribute-value-query(xs:QName("subj-group"), 
xs:QName("subj-group-type"),xs:string(heading)


Note : Create path range index for subject element in your database.


Regards,
Asit Nautiyal

From: 
general-boun...@developer.marklogic.com
 
[general-boun...@developer.marklogic.com]
 on behalf of Chad Bishop 
[cbis...@sciencesocieties.org]
Sent: Wednesday, May 06, 2015 3:04 AM
To: general@developer.marklogic.com
Subject: [MarkLogic Dev General] Searching elements
Greetings,

I’m wondering if someone can help with the best way to approach searching a 
specific element and returning the matching values of that element.

I figured xpath would be best so set this up:

let $term1 := "what"
let $term2 := "ever"

let $subjects := 
fn:collection("content")/article/front/article-meta/article-categories/subj-group[@subj-group-type
 = "heading"]/subject[fn:contains(., $term1) and fn:contains(., $term2)]

for $subject in fn:distinct-values($subjects)
return $subject

However, the number of terms will be variable, so I created this:

let $qtext := "whatever search"
let $terms :=  fn:tokenize($qtext," ")
let $contains := for $term in $terms
 return
  if ($term != $terms[fn:last()])
  then fn:concat("fn:contains(., ", , $term, , ") and ")
  else fn:concat("fn:contains(., ", , $term, , ")")

let $containsText := fn:string-join($contains)

let $subjects := 
fn:collection("content")/article/front/article-meta/article-categories/subj-group[@subj-group-type
 = "heading"]/subject[$containsText]

for $subject in fn:distinct-values($subjects)
return $subject

The problem is the $containsText isn’t evaluated as a function(s).

Is there a way to do that or should I be using something different?

Any help or advice is much appreciated,

-Chad




~~~
Chad Bishop
Lead Developer
Science Societies

Synergy in Science: Partnering for Solutions
2015 ASA, CSSA, and SSSA International Annual Meeting
with the Entomological Society of America
November 15-18 | Minneapolis, Minnesota
www.acsmeetings.org



::DISCLAIMER::

The contents of this e-mail and any attachment(s) are confidential and intended 
for the named recipient(s) only.
E-mail transmission is not guaranteed to be secure or error-free as information 
could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or may contain viruses in 
transmission. The e mail and its contents
(with or without referred errors) shall therefore not attach any liability on 
the originator or HCL or its affiliates.
Views or opinions, if any, presented in this email are solely those of the 
author and may not necessarily reflect the
views or opinions of HCL or its affiliates. Any form of reproduction, 
dissemination, copying, disclosure, modification,

[MarkLogic Dev General] MarkLogic Question

2015-05-06 Thread Cynthia Jiang
Hello,
I have a few questions that I gathered when working with MarkLogic 8 trial 
version on windows 7 enterprise.
What are your recommended configurations on windows server for evaluation and 
data nodes?
A commodity server in 2013 might be a box with 2 CPUs, each 8 cores, 128 
gigabytes of RAM, and either a large local disk or access to a SAN.  On a box 
such as this a rule of thumb is you can store roughly 1 to 2 terabytes of data 
was written in "Inside MarkLogic Server", does it apply to MarkLogic 8 running 
on Windows servers (could be windows 2008R2 or windows 2012 server)?
How data encryption is handled for data file at rest on disk, data field in the 
database etc.?
We have PHI data and we will need to have them encrypted. I didn't find much 
information on how data are encrypted in a MarkLogic 8 database.
How do we set up application authentication so each user can access data 
records only pertinent to the person or certain group level?
We may have multiple levels of user groups, some user can only access data 
pertinent to the person, some user can access data pertinent to certain group 
level. Some user may have access to all the data.
Are there any known issues when running MarkLogic on a windows system that we 
need to be aware of?
What are some of the best ways to query (XQuery) distinct data records?
When multiple objects could join together and there could be one-to-many or 
many-to-many relationship among objects? Or one data element could have 
one-to-many relationship with another data element in a nested json document. 
Some workable examples will help.
The query below was given by MarkLogic and it didn't return the distinct 
records. (in this example, Patient, Claim and PatientAddress are three objects 
and they can be joined together by using PatientIdentifier, a patient can have 
multiple patient addresses, and a patient can also have multiple claims. We 
plan to use nested json format to model all three objects in one document later 
on.)
(
for $patient in /Patient
let $patient-address := /PatientAddress[PatientIdentifier = 
$patient/PatientIdentifier] (:[State eq "LA"]:)
let $claims := /Claim[PatientIdentifier eq $patient/PatientIdentifier]
let $sum :=
  cts:sum-aggregate(
cts:element-reference(xs:QName("MedicalServicesTotalCost")),
(),
cts:element-value-query(xs:QName("PatientIdentifier"), 
$patient/PatientIdentifier))

for $claim in $claims
for $address in $patient-address
let $arr := json:array()
return (
  json:array-push($arr, $patient/PatientIdentifier/fn:string()),
  json:array-push($arr, $address/State/fn:string()),
  json:array-push($arr, $claim/ClaimNumber/fn:string()),
  json:array-push($arr, $sum),
  $arr
)
)[1 to 10]

Why application builder didn't work with Json document when I tried to create 
an application with patient, claim and patient address documents?
Error Message:
http://marklogic.com/xdmp/error error.xsd" 
xmlns:error="http://marklogic.com/xdmp/error"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
  XDMP-CHILDNODEKIND
  
  1.0-ml
  Invalid child node kind
  XDMP-CHILDNODEKIND: fn:doc($uri)[fn:not(binary())] -- 
element nodes cannot have object node children
  false
  fn:doc($uri)[fn:not(binary())]
  
element
object
  
  

  /appbuilder/lib/preview.xqy
  95
  65
  prev:do-preview()
  1.0-ml


  /appbuilder/lib/preview.xqy
  138
  0
  xdmp:invoke("/appbuilder/lib/preview.xqy", 
(fn:QName("","projectxml"), 
fn:doc("/projects/16449182781019934866.xml")/project, fn:QName("","view"), 
...), 6465878920948848186)
  1.0-ml


  /MarkLogic/appservices/utils/common-amped.xqy
  276
  9
  
amped-common:appservices-invoke("/appbuilder/lib/preview.xqy", 
(fn:QName("","projectxml"), 
fn:doc("/projects/16449182781019934866.xml")/project, fn:QName("","view"), 
...), 6465878920948848186)
  
 
   http://marklogic.com/appservices/util-amped";>path
   "/appbuilder/lib/preview.xqy"
 
 
   http://marklogic.com/appservices/util-amped";>vars
   (fn:QName("","projectxml"), 
fn:doc("/projects/16449182781019934866.xml")/project, fn:QName("","view"), 
...)
 
 
   http://marklogic.com/appservices/util-amped";>options
   6465878920948848186
 
  
  1.0-ml


  /appbuilder/lib/render.xqy
  36
  4
  
rend:preview(fn:doc("/projects/16449182781019934866.xml")/project,
 "search", "/PatientDocumentDB/LSU_Claim_31307382.json")
  
 
   http://marklogic.com/appservices/builder/render";>projectxml
   
fn:doc("/projects/16449182781019934866.xml")/project
 
 
   http://marklogic.com/appservices/builder/render";>view
   "search"
 

Re: [MarkLogic Dev General] Searching elements

2015-05-06 Thread Christopher Hamlin
Hi,

The first thing I would wonder, is whether you really need fn:contains
(for substring), or whether you are searching on tokens/words.

If tokens/words, then as mentioned, the search facilities should be
the first option.

/ch


On Tue, May 5, 2015 at 5:34 PM, Chad Bishop
 wrote:
> Greetings,
>
>
>
> I’m wondering if someone can help with the best way to approach searching a
> specific element and returning the matching values of that element.
>
>
>
> I figured xpath would be best so set this up:
>
>
>
> let $term1 := "what"
>
> let $term2 := "ever"
>
>
>
> let $subjects :=
> fn:collection("content")/article/front/article-meta/article-categories/subj-group[@subj-group-type
> = "heading"]/subject[fn:contains(., $term1) and fn:contains(., $term2)]
>
>
>
> for $subject in fn:distinct-values($subjects)
>
> return $subject
>
>
>
> However, the number of terms will be variable, so I created this:
>
>
>
> let $qtext := "whatever search"
>
> let $terms :=  fn:tokenize($qtext," ")
>
> let $contains := for $term in $terms
>
>  return
>
>   if ($term != $terms[fn:last()])
>
>   then fn:concat("fn:contains(., ", , $term, , ")
> and ")
>
>   else fn:concat("fn:contains(., ", , $term, , ")")
>
>
>
> let $containsText := fn:string-join($contains)
>
>
>
> let $subjects :=
> fn:collection("content")/article/front/article-meta/article-categories/subj-group[@subj-group-type
> = "heading"]/subject[$containsText]
>
>
>
> for $subject in fn:distinct-values($subjects)
>
> return $subject
>
>
>
> The problem is the $containsText isn’t evaluated as a function(s).
>
>
>
> Is there a way to do that or should I be using something different?
>
>
>
> Any help or advice is much appreciated,
>
>
>
> -Chad
>
>
>
>
>
>
>
>
>
> ~~~
>
> Chad Bishop
>
> Lead Developer
>
> Science Societies
>
>
>
> Synergy in Science: Partnering for Solutions
>
> 2015 ASA, CSSA, and SSSA International Annual Meeting
>
> with the Entomological Society of America
>
> November 15-18 | Minneapolis, Minnesota
>
> www.acsmeetings.org
>
>
>
>
> ___
> General mailing list
> General@developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] Calculating Node size

2015-05-06 Thread Mary Holstege
Use fn:string instead of xdmp:quote

On May 6, 2015 5:32 AM, Jonna Marry  wrote:
Hi,

We need to calculate the character length of a Node. By applying xpath we are 
getting the sequence of nodes. We need to calculate the length of each node 
along with nodename and text values. Since we have same name space in all the 
element we want to ignore the namespace char length.

Is there any way to ignore namespaces only for size calculation.

For example:

let $nodes := (http://www.aaa-aaa.com/info";>Logging Ltd.1 ,
http://www.aaa-aaa.com/info";>Logging 
Ltd2.,
http://www.aaa-aaa.com/info";>Logging 
Ltd.3,
http://www.aaa-aaa.com/info";>Logging 
Ltd4.
)

For single node
Without namespace  size= 48
With namespace  size= 88

currently we are using fn:string-length( xdmp:quote($nodes[1])).

Regards,
Jonna
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] Calculating Node size

2015-05-06 Thread Jonna Marry
Hi,

We need to calculate the character length of a Node. By applying xpath we
are getting the sequence of nodes. We need to calculate the length of each
node along with nodename and text values. Since we have same name space in
all the element we want to ignore the namespace char length.

Is there any way to ignore namespaces only for size calculation.

For example:

let $nodes := (http://www.aaa-aaa.com/info";>Logging
Ltd.1 ,
http://www.aaa-aaa.com/info";>Logging
Ltd2.,
http://www.aaa-aaa.com/info";>Logging
Ltd.3,
http://www.aaa-aaa.com/info";>Logging
Ltd4.
)

For single node
Without namespace  size= 48
With namespace  size= 88

currently we are using fn:string-length( xdmp:quote($nodes[1])).

Regards,
Jonna
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general