search:search 选项从 MarkLogic 7 迁移到版本 8

search:search options migration from MarkLogic 7 to version 8

我正在尝试将一个用 XQuery 编写的搜索应用程序从 MarkLogic 7 迁移到版本 8,我遇到了这个关于选项中的约束命名空间的已知不兼容问题。我尝试添加默认的 json/basic 命名空间,然后添加自定义命名空间,但没有用。当我 运行 查询控制台网页中的以下代码断开连接并在几秒钟后重新加载。我什至重新创建了一个元素范围索引,在我安装 ML 8 之后我的所有数据库都被识别,我已经重新索引了目标数据库。不知道还有什么问题。任何指导将不胜感激,谢谢!

xquery version "1.0-ml";

import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";

declare variable $options := 
<search:options xmlns:search="http://marklogic.com/appservices/search">
  <search:search-option>unfiltered</search:search-option>
  <search:page-length>30</search:page-length>
  <search:term apply="term">
    <search:empty apply="all-results"/>
    <search:term-option>punctuation-insensitive</search:term-option>
    <search:term-option>stemmed</search:term-option>
  </search:term>
  <search:grammar>
    <search:quotation>"</search:quotation>
    <search:implicit>
      <cts:and-query strength="20" xmlns:cts="http://marklogic.com/cts"/>
    </search:implicit>
    <search:starter strength="30" apply="grouping" delimiter=")">(</search:starter>
    <search:starter strength="40" apply="prefix" element="cts:not-query">-</search:starter>
    <search:joiner strength="10" apply="infix" element="cts:or-query" tokenize="word">OR</search:joiner>
    <search:joiner strength="20" apply="infix" element="cts:and-query" tokenize="word">AND</search:joiner>
    <search:joiner strength="30" apply="infix" element="cts:near-query" tokenize="word">NEAR</search:joiner>
    <search:joiner strength="30" apply="near2" consume="2" element="cts:near-query">NEAR/</search:joiner>
    <search:joiner strength="50" apply="constraint">:</search:joiner>
    <search:joiner strength="50" apply="constraint" compare="LT" tokenize="word">LT</search:joiner>
    <search:joiner strength="50" apply="constraint" compare="LE" tokenize="word">LE</search:joiner>
    <search:joiner strength="50" apply="constraint" compare="GT" tokenize="word">GT</search:joiner>
    <search:joiner strength="50" apply="constraint" compare="GE" tokenize="word">GE</search:joiner>
    <search:joiner strength="50" apply="constraint" compare="NE" tokenize="word">NE</search:joiner>
  </search:grammar>
  <search:additional-query>
    <cts:not-query xmlns:cts="http://marklogic.com/cts">
      <cts:or-query>
    <cts:collection-query>
      <cts:uri>ontology</cts:uri>
      <cts:uri>Gemeentes</cts:uri>
      <cts:uri>Wijken</cts:uri>
      <cts:uri>Buurten</cts:uri>
      <cts:uri>Wijk_Hierarchy</cts:uri>
      <cts:uri>Buurt_Hierarchy</cts:uri>
      <cts:uri>Kerncijfers_wijken_en_buurten_2014</cts:uri>
    </cts:collection-query>
    <cts:element-query>
      <cts:element xmlns:sem="http://marklogic.com/semantics">sem:triples</cts:element>
      <cts:or-query/>
    </cts:element-query>
      </cts:or-query>
    </cts:not-query>
  </search:additional-query>
  <search:debug>false</search:debug>
  <search:extract-metadata>
    <search:qname elem-name="Vhe"/>
    <search:qname elem-name="OpnameType"/>
    <search:qname elem-name="Plaats"/>
    <search:qname elem-name="Straat"/>
      <search:constraint-value ref="Plaats"/>
    <search:constraint-value ref="Straat"/>
    <search:constraint-value ref="Keuken_Beoordeling"/>
      <search:constraint-value ref="Badkamer_Beoordeling"/>
    <search:constraint-value ref="location"/>
  </search:extract-metadata>

  <search:transform-results apply="snippet"/>

  <search:constraint name="location">
    <search:geo-elem-pair>
      <search:parent name="location"/>
      <search:lat name="lat"/>
      <search:lon name="lng"/>
      <search:geo-option>units=miles</search:geo-option>
      <search:geo-option>coordinate-system=wgs84</search:geo-option>
      <search:heatmap n="50.0006240" s="52.384274889550028" w="5.1864790" e="6.8864790" latdivs="14" londivs="19"/>
    </search:geo-elem-pair>
  </search:constraint>

  <search:constraint name="Plaats">
    <search:range type="xs:string" collation="http://marklogic.com/collation/">
      <search:element name="Plaats"/>
    </search:range>
  </search:constraint>
  <search:constraint name="Straat">
    <search:range type="xs:string" collation="http://marklogic.com/collation/">
      <search:element name="Straat"/>
    </search:range>
  </search:constraint>
  <search:constraint name="Complex">
    <search:range type="xs:string" collation="http://marklogic.com/collation/">
      <search:element name="Complex"/>
    </search:range>
  </search:constraint>
  <search:constraint name="Keuken_Beoordeling">
    <search:range type="xs:string" collation="http://marklogic.com/collation/">
      <search:element name="Keuken_Beoordeling"/>
    </search:range>
  </search:constraint>
  <search:constraint name="Badkamer_Beoordeling">
    <search:range type="xs:string" collation="http://marklogic.com/collation/">
      <search:element name="Badkamer_Beoordeling"/>
    </search:range>
  </search:constraint>
  <search:return-metrics>true</search:return-metrics>
  <search:return-qtext>true</search:return-qtext>
  <search:return-query>false</search:return-query>
  <search:return-results>true</search:return-results>
  <search:return-similar>false</search:return-similar>
  <search:sort-order direction="descending">
  <search:score/>
  <search:annotation>Relevancy (Desc)</search:annotation>
</search:sort-order>
</search:options>;

 search:search("wieer", $options, xs:unsignedLong(1), 150) 

正如乔指出的那样,服务器可能会崩溃并自动重启。检查 ErrorLog.txt 以验证这一点。确保你有 very latest release:现在是 8.0-1.1。

测试用例不会在我的笔记本电脑上崩溃,带有 8.0-1.1 和必要的索引设置。但是我没有任何匹配的文件,所以它做的不多。这可能意味着崩溃(如果发生这种情况)也需要您的一些内容。您可以尝试一个空数据库来验证这一点,然后尝试确定问题是否与一组特定的文档有关。

如果问题仍然存在,contact support 报告。

我从头开始重新创建了数据库,将带有最新 mlcp 的数据从 ML 7 数据库复制到新创建的 ML 8 数据库。重新创建索引,但崩溃仍在发生。然后,我从搜索选项中过滤掉了导致崩溃的部分。就是这个:

  <search:constraint name="location">
    <search:geo-elem-pair>
      <search:parent name="location"/>
      <search:lat name="lat"/>
      <search:lon name="lng"/>
      <search:geo-option>units=miles</search:geo-option>
      <search:geo-option>coordinate-system=wgs84</search:geo-option>
      <search:heatmap n="50.0006240" s="52.384274889550028" w="5.1864790" e="6.8864790" latdivs="14" londivs="19"/>
    </search:geo-elem-pair>
  </search:constraint>

我删除它后,并没有真正在搜索结果中使用它,就没有更多问题了。