MarkLogic

时间:2015-05-07 10:53:16

标签: marklogic

由于 databases.xsd ,在 MarkLogic 7 中似乎无法在添加字段期间将所有不同选项添加到字段xml中,就像在 MarkLogic 5 中一样。 例如:

 <three-character-searches> true </three-character-searches>
 <three-character-word-positions> true </three-character-word-positions>
 <two-character-searches> true </two-character-searches>

我添加的选项很少。有什么方法可以一次性添加它们,而不是为每个选项使用API​​,例如,

  

管理员:数据库设置场梗的搜索

修改

下面的代码可以在ML 5.0.5上运行。

 xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
          at "/MarkLogic/admin.xqy";

let $field:=<field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://marklogic.com/xdmp/database">
      <field-name>myField</field-name>
      <include-root>false</include-root>
      <word-lexicons>
        <word-lexicon>http://marklogic.com/collation/codepoint</word-lexicon>
      </word-lexicons>
      <stemmed-searches>decompounding</stemmed-searches>
      <word-searches>true</word-searches>
      <fast-phrase-searches>true</fast-phrase-searches>
      <fast-case-sensitive-searches>true</fast-case-sensitive-searches>
      <fast-diacritic-sensitive-searches>true</fast-diacritic-sensitive-searches>
      <trailing-wildcard-searches>true</trailing-wildcard-searches>
      <trailing-wildcard-word-positions>true</trailing-wildcard-word-positions>
      <three-character-searches>true</three-character-searches>
      <three-character-word-positions>true</three-character-word-positions>
      <two-character-searches>true</two-character-searches>
      <one-character-searches>true</one-character-searches>
      <included-elements>
        <included-element>
          <namespace-uri>ns</namespace-uri>
          <localname>in</localname>
          <weight>9</weight>
          <attribute-namespace-uri/>
          <attribute-localname/>
          <attribute-value/>
        </included-element>
       </included-elements>
      <excluded-elements>
        <excluded-element>
          <namespace-uri>ns</namespace-uri>
          <localname>ex</localname>
        </excluded-element>
      </excluded-elements>
    </field>



let $config := admin:get-configuration()

let $config:=admin:database-add-field($config,xdmp:database(),$field)
return admin:save-configuration($config)

1 个答案:

答案 0 :(得分:0)

看起来它对订单特别重要。我将您的代码与MarkLogic通过管理界面创建字段时记录的内容进行了比较。基于此,我移动了&lt; word-lexicons&gt;再向下。

xquery version "1.0-ml";

import module namespace admin = "http://marklogic.com/xdmp/admin" 
          at "/MarkLogic/admin.xqy";

let $field:=
  <field xmlns="http://marklogic.com/xdmp/database" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <field-name>myField</field-name>
    <include-root>false</include-root>
    <stemmed-searches>decompounding</stemmed-searches>
    <word-searches>true</word-searches>
    <fast-phrase-searches>true</fast-phrase-searches>
    <fast-case-sensitive-searches>true</fast-case-sensitive-searches>
    <fast-diacritic-sensitive-searches>true</fast-diacritic-sensitive-searches>
    <trailing-wildcard-searches>true</trailing-wildcard-searches>
    <trailing-wildcard-word-positions>true</trailing-wildcard-word-positions>
    <three-character-searches>true</three-character-searches>
    <three-character-word-positions>true</three-character-word-positions>
    <two-character-searches>true</two-character-searches>
    <one-character-searches>true</one-character-searches>
    <word-lexicons>
      <word-lexicon>http://marklogic.com/collation/codepoint</word-lexicon>
    </word-lexicons>
    <included-elements>
      <included-element>
        <namespace-uri>ns</namespace-uri>
        <localname>in</localname>
        <weight>9</weight>
        <attribute-namespace-uri/>
        <attribute-localname/>
        <attribute-value/>
      </included-element>
    </included-elements>
    <excluded-elements>
      <excluded-element>
        <namespace-uri>ns</namespace-uri>
        <localname>ex</localname>
      </excluded-element>
    </excluded-elements>
  </field>

let $config := admin:get-configuration()
let $config:=admin:database-add-field($config, xdmp:database(), $field)
return admin:save-configuration($config)

那很有用。

话虽如此,我觉得有必要指出你正在使用API​​而不是使用它,感觉很脆弱。谨慎行事。