Re: [MarkLogic Dev General] Full-text search and JSON

2017-11-07 Thread Geert Josten
Well, you could give your json doc a root property.. :)

{ root: { id: 1234, text: ³brown fox² } }

Cheers

On 11/8/17, 4:03 AM, "general-boun...@developer.marklogic.com on behalf of
Will Thompson"  wrote:

>Hi Rob,
>
>Likewise! I think I just figured it out. I am excluding root in the word
>query index settings. The root of the document I was searching for is an
>object-node though, so I suspect there's no way to include it.
>
>-Will
>
>
>> On Nov 7, 2017, at 8:36 PM, Rob Szkutak 
>>wrote:
>> 
>> Hi Will,
>> 
>> I hope you are doing well. It's nice to see your name pop up.
>> 
>> I tested out your example on a new database in ML 9.0-3 and it worked
>>just fine for me. Can you try to fn:doc() the document and make sure you
>>can see it? If you can, check to make sure your document is not a binary
>>node with xdmp:node-kind(fn:doc("/test.json")/node()) .
>> 
>> Best,
>> Rob
>> 
>> Rob Szkutak
>> Senior Consultant
>> MarkLogic Corporation
>> www.marklogic.com
>> 
>> From: general-boun...@developer.marklogic.com
>> on behalf of Will Thompson
>>
>> Sent: Tuesday, November 7, 2017 5:36:31 PM
>> To: MarkLogic Developer Discussion
>> Subject: [MarkLogic Dev General] Full-text search and JSON
>>  
>> Is it possible to search generally against text tokens in JSON
>>documents? All of the JSON-specific cts:queries require property names,
>>and cts:word-query doesn't appear to match JSON documents. For example,
>>if I have a document with URI "/test.json":
>> 
>> {
>>   "id" : 1234,
>>   "text" : "The quick brown fox jumps over the lazy dog."
>> }
>> 
>> cts:search(doc(), "brown fox") returns empty. Is there another way to
>>do this?
>> 
>> -Will
>> ___
>> 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:
>> 
>>https://urldefense.proofpoint.com/v2/url?u=http-3A__developer.marklogic.c
>>om_mailman_listinfo_general=DwICAg=IdrBOxAMwHPzAikPNzltHw=_thRNTuzv
>>zYaEDwaA_AfnAe5hN2lWgi6qdluz6ApLYI=IL-JssAmKFbFz-tiCY8C6KCgrkw4LBVMCgi9
>>znH0jKM=1DKnkzzBpnXr44ZMhD1XHTPdzU8QtXT0Ie0dhXUx-3o=
>
>___
>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] Full-text search and JSON

2017-11-07 Thread Will Thompson
Hi Rob,

Likewise! I think I just figured it out. I am excluding root in the word query 
index settings. The root of the document I was searching for is an object-node 
though, so I suspect there's no way to include it. 

-Will


> On Nov 7, 2017, at 8:36 PM, Rob Szkutak  wrote:
> 
> Hi Will,
> 
> I hope you are doing well. It's nice to see your name pop up.
> 
> I tested out your example on a new database in ML 9.0-3 and it worked just 
> fine for me. Can you try to fn:doc() the document and make sure you can see 
> it? If you can, check to make sure your document is not a binary node with 
> xdmp:node-kind(fn:doc("/test.json")/node()) .
> 
> Best,
> Rob
> 
> Rob Szkutak
> Senior Consultant
> MarkLogic Corporation
> www.marklogic.com
> 
> From: general-boun...@developer.marklogic.com 
>  on behalf of Will Thompson 
> 
> Sent: Tuesday, November 7, 2017 5:36:31 PM
> To: MarkLogic Developer Discussion
> Subject: [MarkLogic Dev General] Full-text search and JSON
>  
> Is it possible to search generally against text tokens in JSON documents? All 
> of the JSON-specific cts:queries require property names, and cts:word-query 
> doesn't appear to match JSON documents. For example, if I have a document 
> with URI "/test.json":
> 
> {
>   "id" : 1234,
>   "text" : "The quick brown fox jumps over the lazy dog."
> }
> 
> cts:search(doc(), "brown fox") returns empty. Is there another way to do this?
> 
> -Will
> ___
> 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: 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__developer.marklogic.com_mailman_listinfo_general=DwICAg=IdrBOxAMwHPzAikPNzltHw=_thRNTuzvzYaEDwaA_AfnAe5hN2lWgi6qdluz6ApLYI=IL-JssAmKFbFz-tiCY8C6KCgrkw4LBVMCgi9znH0jKM=1DKnkzzBpnXr44ZMhD1XHTPdzU8QtXT0Ie0dhXUx-3o=

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


Re: [MarkLogic Dev General] Full-text search and JSON

2017-11-07 Thread Rob Szkutak
Hi Will,


I hope you are doing well. It's nice to see your name pop up.


I tested out your example on a new database in ML 9.0-3 and it worked just fine 
for me. Can you try to fn:doc() the document and make sure you can see it? If 
you can, check to make sure your document is not a binary node with 
xdmp:node-kind(fn:doc("/test.json")/node()) .


Best,

Rob


Rob Szkutak
Senior Consultant
MarkLogic Corporation
www.marklogic.com


From: general-boun...@developer.marklogic.com 
 on behalf of Will Thompson 

Sent: Tuesday, November 7, 2017 5:36:31 PM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Full-text search and JSON

Is it possible to search generally against text tokens in JSON documents? All 
of the JSON-specific cts:queries require property names, and cts:word-query 
doesn't appear to match JSON documents. For example, if I have a document with 
URI "/test.json":

{
  "id" : 1234,
  "text" : "The quick brown fox jumps over the lazy dog."
}

cts:search(doc(), "brown fox") returns empty. Is there another way to do this?

-Will
___
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


[MarkLogic Dev General] Full-text search and JSON

2017-11-07 Thread Will Thompson
Is it possible to search generally against text tokens in JSON documents? All 
of the JSON-specific cts:queries require property names, and cts:word-query 
doesn't appear to match JSON documents. For example, if I have a document with 
URI "/test.json":

{
  "id" : 1234,
  "text" : "The quick brown fox jumps over the lazy dog."
}

cts:search(doc(), "brown fox") returns empty. Is there another way to do this?

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


[MarkLogic Dev General] xsl:output, character maps and document-insert

2017-11-07 Thread Mark Donoghue
Hi,

I am running a query in the query console that retrieves a document from
the database, invokes an XSLT and stores the result over the same document
URI.

The purpose of the XSLT is to unescape double-escaped character entities
(i.e.: amp;). Following what I thought was standard practice, the XSLT
replaces &'s with  and uses a character map to swap the private
character with an ampersand on output (using the use-character-maps on the
xsl:output element).

This works fine in oXygen and even in the query console tests where I
output the result document to the output pane.

The problem occurs when I retrieve the document from the database. The
private character  is still in the result document I stored, and
hasn't been replaced with an ampersand.

Does document-insert (or something) ignore the xsl:output directives in the
stylesheet?

Am I running into some some query console behavior I'm not aware of (I'm
still rather new at using MarkLogic).

Any pointers in the right direction will he much appreciated.

Best,
Mark

- -- --- -  -
Mark Donoghue
IEEE
(732) 562-6045
m.donog...@ieee.org

IEEE - Advancing Technology for Humanity
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] Document access based on field value

2017-11-07 Thread Shmennen
Thank you all!
-Ric 
 
  On Tue, Nov 7, 2017 at 22:11, Geert Josten wrote: 
  Hi Richard,
It is usually easiest to build up a few layers of roles. Most flexibility is 
gained when you create separate read and update roles for each group of 
documents to which you want to control access separately. You can then use role 
inheritance to give a user or usergroup-specific role access to particular 
groups of documents. You could also create one that has access to all.
To save on cross-products of roles, I’d also advice looking into compartment 
security. That allows restricting access to combinations of roles, bit like AND 
(compartments) versus OR (default behavior)..
Cheers,Geert
From:  on behalf of Shmennen 

Reply-To: "shmen...@yahoo.com" , MarkLogic Developer 
Discussion 
Date: Tuesday, November 7, 2017 at 9:57 PM
To: Rob Szkutak , MarkLogic Developer Discussion 

Subject: Re: [MarkLogic Dev General] Document access based on field value

Thanks, it looks good!
Btw, another question, may be not related: is there any way to assign some 
capabilities (e.g. insert, update, execute) to an user who can access all docs, 
no matter what roles and privileges they have in db? E.g. some power user to 
have access (read/write) to all docs, independent of users they were inserted, 
but to not be admin.
RegardsRichard W.


On Tue, Nov 7, 2017 at 19:20, Rob Szkutak 
wrote:#yiv9954050599 -- P {margin-top:0;margin-bottom:0;}#yiv9954050599 
Hello,




One solution to implement this is to use amplified functions (amps).




The basic idea is this:




* Restrict the document so that the user cannot read or update it. 

* Create a function which the user must use to read or update the document. 

* Amplify the function so that the user can read or modify the document only 
within your function.

* Have your function perform the validation check and either perform the 
desired document operation or return the appropriate invalid document response 
to the user.







Another solution is that every time a document is inserted or updated, you 
could perform a check if the document is valid or not and assign the 
appropriate role to it when the document is placed into the database. 




Something like : 

let $valid := true or false

return

 xdmp:document-insert("uri", $document, if($valid) then xdmp:permission("user 
can read") else xdmp:permission("user cannot read"))







If required you may also combine these two techniques.




Hope this is helpful.




Best,

Rob



Rob SzkutakSenior ConsultantMarkLogic Corporationwww.marklogic.com
From:general-boun...@developer.marklogic.com 
 on behalf of Shmennen 

Sent: Tuesday, November 7, 2017 10:54:40 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Document access based on field value Hello All,
   Is there any possibility to get access to a document (suppose an XML or 
JSON) from database only if the value of a tag has a specific values?
E.g. user1can read/modify document if only checktag has value "VALID".    
 999
    VALID

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


Re: [MarkLogic Dev General] Document access based on field value

2017-11-07 Thread Geert Josten
Hi Richard,

It is usually easiest to build up a few layers of roles. Most flexibility is 
gained when you create separate read and update roles for each group of 
documents to which you want to control access separately. You can then use role 
inheritance to give a user or usergroup-specific role access to particular 
groups of documents. You could also create one that has access to all.

To save on cross-products of roles, I’d also advice looking into compartment 
security. That allows restricting access to combinations of roles, bit like AND 
(compartments) versus OR (default behavior)..

Cheers,
Geert

From: 
>
 on behalf of Shmennen >
Reply-To: "shmen...@yahoo.com" 
>, MarkLogic Developer Discussion 
>
Date: Tuesday, November 7, 2017 at 9:57 PM
To: Rob Szkutak >, 
MarkLogic Developer Discussion 
>
Subject: Re: [MarkLogic Dev General] Document access based on field value

Thanks, it looks good!

Btw, another question, may be not related: is there any way to assign some 
capabilities (e.g. insert, update, execute) to an user who can access all docs, 
no matter what roles and privileges they have in db?
E.g. some power user to have access (read/write) to all docs, independent of 
users they were inserted, but to not be admin.

Regards
Richard W.


On Tue, Nov 7, 2017 at 19:20, Rob Szkutak
> wrote:

Hello,


One solution to implement this is to use amplified functions (amps).


The basic idea is this:


* Restrict the document so that the user cannot read or update it.

* Create a function which the user must use to read or update the document.

* Amplify the function so that the user can read or modify the document only 
within your function.

* Have your function perform the validation check and either perform the 
desired document operation or return the appropriate invalid document response 
to the user.



Another solution is that every time a document is inserted or updated, you 
could perform a check if the document is valid or not and assign the 
appropriate role to it when the document is placed into the database.


Something like :

let $valid := true or false

return

 xdmp:document-insert("uri", $document, if($valid) then xdmp:permission("user 
can read") else xdmp:permission("user cannot read"))



If required you may also combine these two techniques.


Hope this is helpful.


Best,

Rob


Rob Szkutak
Senior Consultant
MarkLogic Corporation
www.marklogic.com


From: 
general-boun...@developer.marklogic.com
 
>
 on behalf of Shmennen >
Sent: Tuesday, November 7, 2017 10:54:40 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Document access based on field value

Hello All,

   Is there any possibility to get access to a document (suppose an XML or 
JSON) from database only if the value of a tag has a specific values?

E.g. user1 can read/modify document if only check tag has value "VALID".

999
VALID


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


Re: [MarkLogic Dev General] Document access based on field value

2017-11-07 Thread Shmennen
Thanks, it looks good!
Btw, another question, may be not related: is there any way to assign some 
capabilities (e.g. insert, update, execute) to an user who can access all docs, 
no matter what roles and privileges they have in db? E.g. some power user to 
have access (read/write) to all docs, independent of users they were inserted, 
but to not be admin.
RegardsRichard W.

 
  On Tue, Nov 7, 2017 at 19:20, Rob Szkutak wrote:   
#yiv8687077562 #yiv8687077562 -- P 
{margin-top:0;margin-bottom:0;}#yiv8687077562 
Hello,




One solution to implement this is to use amplified functions (amps).




The basic idea is this:




* Restrict the document so that the user cannot read or update it. 

* Create a function which the user must use to read or update the document. 

* Amplify the function so that the user can read or modify the document only 
within your function.

* Have your function perform the validation check and either perform the 
desired document operation or return the appropriate invalid document response 
to the user.







Another solution is that every time a document is inserted or updated, you 
could perform a check if the document is valid or not and assign the 
appropriate role to it when the document is placed into the database. 




Something like : 

let $valid := true or false

return

 xdmp:document-insert("uri", $document, if($valid) then xdmp:permission("user 
can read") else xdmp:permission("user cannot read"))







If required you may also combine these two techniques.




Hope this is helpful.




Best,

Rob



Rob SzkutakSenior ConsultantMarkLogic Corporationwww.marklogic.com
From: general-boun...@developer.marklogic.com 
 on behalf of Shmennen 

Sent: Tuesday, November 7, 2017 10:54:40 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Document access based on field value Hello All,
   Is there any possibility to get access to a document (suppose an XML or 
JSON) from database only if the value of a tag has a specific values?
E.g. user1 can read/modify document if only checktag has value "VALID".   
  999
    VALID

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


Re: [MarkLogic Dev General] Document access based on field value

2017-11-07 Thread Rob Szkutak
Hello,


One solution to implement this is to use amplified functions (amps).


The basic idea is this:


* Restrict the document so that the user cannot read or update it.

* Create a function which the user must use to read or update the document.

* Amplify the function so that the user can read or modify the document only 
within your function.

* Have your function perform the validation check and either perform the 
desired document operation or return the appropriate invalid document response 
to the user.



Another solution is that every time a document is inserted or updated, you 
could perform a check if the document is valid or not and assign the 
appropriate role to it when the document is placed into the database.


Something like :

let $valid := true or false

return

 xdmp:document-insert("uri", $document, if($valid) then xdmp:permission("user 
can read") else xdmp:permission("user cannot read"))



If required you may also combine these two techniques.


Hope this is helpful.


Best,

Rob


Rob Szkutak
Senior Consultant
MarkLogic Corporation
www.marklogic.com


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

Sent: Tuesday, November 7, 2017 10:54:40 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Document access based on field value

Hello All,

   Is there any possibility to get access to a document (suppose an XML or 
JSON) from database only if the value of a tag has a specific values?

E.g. user1 can read/modify document if only check tag has value "VALID".

999
VALID


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


[MarkLogic Dev General] Document access based on field value

2017-11-07 Thread Shmennen
Hello All,
   Is there any possibility to get access to a document (suppose an XML or 
JSON) from database only if the value of a tag has a specific values?
E.g. user1 can read/modify document if only check tag has value "VALID".  
   999
    VALID

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