提高 search:search 结果检索速度性能的提示?

Hints to improve speed performance for a search:search results retrieval?

我正在使用 search:search 检索相当大的数据集(0.5K 到 3K)来绘制一些图表,并且还使用搜索 API 中的方面好东西来允许最终用户对数据集进行分面过滤,然后动态重建图表。从数据库中检索数据并将数据提取到客户端 Web 应用程序需要付出代价,大约需要 5-10 秒(当数据集较小时更少),这对最终用户来说不是很愉快。我知道这是一个概念性问题,在允许用户轻松塑造正在绘制的数据和此过程的速度之间存在细微的 balance/compromise,但是,任何 help/hints 将不胜感激。谢谢!

P.S.: 我尝试使用 search:parse 然后将查询传递给 cts:query 引发了这样的错误:[1.0-ml] XDMP-NONMIXEDCOMPLEXCONT: fn:data(<cts:and-query qtextjoin="AND" strength="20" qtextgroup="( )" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cts="http://marklogic.com/cts"><cts:element-range-query qtextpre="Jaar:" qtextref="cts:annotati...</cts:and-query>) -- Node has complex type with non-mixed complex content

选项:

<search:options xmlns:search="http://marklogic.com/appservices/search">
  <search:search-option>filtered</search:search-option>
  <search:page-length>3050</search:page-length>
  <search:term apply="term">
    <search:empty apply="all-results"/>
    <search:term-option>punctuation-insensitive</search:term-option>
    <search:term-option>unstemmed</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>All_Intakes</cts:uri>
      <cts:uri>Reports</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="USER_EI"/>
    <search:qname elem-name="Customer"/>
    <search:qname elem-name="TOTALAMOUNTTENANTEI"/>
    <search:qname elem-name="TOTALAMOUNTTENANTEI2"/>
    <search:constraint-value ref="Medewerker"/>
    <search:constraint-value ref="Klant"/>
    <search:constraint-value ref="TOTALAMOUNTTENANTEI"/>
    <search:constraint-value ref="TOTALAMOUNTTENANTEI2"/>
  </search:extract-metadata>

  <search:transform-results apply="snippet"/>
    <search:constraint name="Klant">
    <search:range type="xs:string" collation="http://marklogic.com/collation/">
      <search:element name="Customer"/>
    </search:range>
  </search:constraint>
  <search:constraint name="Medewerker">
    <search:range type="xs:string" collation="http://marklogic.com/collation/">
      <search:element name="USER_EI"/>
    </search:range>
  </search:constraint>
  <search:constraint name="Jaar">
    <search:range type="xs:int">
      <search:element name="Operation_Year"/>
    </search:range>
  </search:constraint>
  <search:constraint name="Kwartaal">
    <search:range type="xs:int">
      <search:element name="Operation_Quarter"/>
    </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>;

听起来您正试图在一页中获取完整的搜索结果 (start=1 page-length=99999999)。您可能希望将策略更改为以较小的批次(page-length=100?)获取结果,并简单地遍历页面,并动态地将越来越多的节点附加到图表中。一个好的图表库应该支持这一点。

HTH!

您提到想要绘制图表和创建构面。两者都将基于价值而不是完整的文件。在我看来,您可以 return,比方说 10 个文档值,但从您的方面获得更大的列表。看起来您目前正在从提取元数据中获取值。这是获取一些信息以显示有关单个搜索结果的好方法,但不是获取有关数据集的摘要信息的好方法。

您的约束全部使用范围索引,这很好 -- 这些问题会很快得到解决。对于您的图表,您可能希望使用 /v1/values 来获取同现值。

我会将您的页面长度更改为 10,并将 limit=100 添加到构面,然后从构面而不是提取元数据中获取图表值。此外,如果您可以安排索引以便 unfiltered searches 提供准确的结果,那么您的搜索将 运行 更快。