If you want to save yourself some configuring in the Admin Interface, you can 
always use the Admin API to take the word query field (the field with no name), 
and then transform it to have a name and add it to your configuration, sort of 
like a clone function.  Here is an example (I would test it before using it...):

xquery version "1.0-ml";

import module namespace admin = "http://marklogic.com/xdmp/admin"; 
                  at "/MarkLogic/admin.xqy";
declare namespace db="http://marklogic.com/xdmp/database";;
                
declare function local:passthru($x as node()) as node()*
{
for $z in $x/node() return local:dispatch($z)
};

(: This is the recursive typeswitch function :)
declare function local:dispatch($x as node()) as node()*
{
typeswitch ($x)
  case text() return $x
  case element (db:field-name) return 
       if ( fn:empty($x/text() ) )
       then <db:field-name>my-new-field</db:field-name>
       else $x
  default return element {fn:node-name($x)} {$x/@*, 
                         local:passthru($x)}
};

let $config := admin:get-configuration()
let $wq-field :=  admin:database-get-field($config, 
      xdmp:database("Documents"), "")
let $new-field := local:dispatch($wq-field)
return
admin:database-add-field($config, xdmp:database("Documents"), 
$new-field)//db:fields

-Danny

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Michael Sokolov
Sent: Thursday, January 27, 2011 4:20 PM
To: General MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] excluding elements from fields

OK, thanks.


On 1/27/2011 3:00 PM, Michael Blakeley wrote:
> I think not. You can think of word-query as its own field, independent of any 
> other fields you might create.
>
> -- Mike
>
> On Jan 27, 2011, at 11:51, Mike Sokolov<[email protected]>  wrote:
>
>> Quick question: are elements excluded from word-query inherited by field
>> configuration, as other database-wide config is?  IE are they also
>> excluded from any field by default?  I thought they would be, but then I
>> couldn't find any mention of this in the documentation, which leads to
>> me to believe that one needs to redefine any exclusions explicitly for
>> each field.  Is that right?
>>
>> Thanks
>>
>> -- 
>> Michael Sokolov
>> Engineering Director
>> www.ifactory.com
>> @iFactoryBoston
>>
>> PubFactory: the revolutionary e-publishing platform from iFactory
>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to