简体   繁体   English

Marklogic Xquery搜索:搜索项-选项

[英]Marklogic Xquery search:search term-option

Below query gives me wrong result count: 下面的查询给我错误的结果计数:

<options xmlns="http://marklogic.com/appservices/search">     
  <constraint name="Keyword">
    <range type="xs:string" 
           facet="true" 
           collation="http://marklogic.com/collation/">
      <element ns="" name="keyword"/>
      <facet-option>frequency-order</facet-option>
      <facet-option>descending</facet-option>
      <facet-option>limit=1</facet-option>
    </range>
  </constraint>
</options>;
let $query-text  := "pankaj!"
let $response := search:search($query-text, $query-options1)
return $response

there is no word "pankaj!" 没有单词“ pankaj!” in my ML DB, but it gives 33 response. 在我的ML DB中,但给出了33条响应。 33 is true for word "pankaj" but not for "pankaj!". 33对于单词“ pankaj”是正确的,但对于“ pankaj!”则不是。 "!" “!” is getting removed from the query text. 从查询文本中删除。

<search:response snippet-format="snippet" 
  total="33" 
  start="1" 
  page-length="10" 
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns="" 
  xmlns:search="http://marklogic.com/appservices/search"> 

Please let me know how to set term-option to get correct result. 请让我知道如何设置term-option以获得正确的结果。

Thanks. 谢谢。

Both wst and mblakele have usefull remarks, but there is still one more issue with your code. wst和mblakele都有有用的说明,但是您的代码仍然存在另一个问题。 You declare a facet, which you can use for fielded search. 您声明一个构面,可将其用于现场搜索。 But you are not using it. 但是您没有使用它。 You need to prepend "Keyword:" in front of your search term. 您需要在搜索词前添加“关键字:”。

If you don't the search term is treated as a word query, and that will cause punctuation to be removed as mblakele explains. 如果您不这样做,则搜索词将被视为单词查询,这将导致删除标点符号,如mblakele所述。 Using the prefix should improve the count, if your search term occurs outside keyword elements as well. 如果您的搜索字词也出现在关键字元素之外,则使用前缀可以提高计数。 To get what you really want, the hints from wst and Will to add punctuation-sensitive are probably valuable too.. 为了获得您真正想要的东西,来自wst和Will的提示对标点符号敏感可能也很有价值。

HTH! HTH!

Word indexes are not punctuation-sensitive, because words are not punctuation. 单词索引不是标点符号敏感的,因为单词不是标点符号。 I recommend reading http://developer.marklogic.com/try/ninja/page8 to understand the various query options and http://docs.marklogic.com/guide/search-dev/count_estimate to understand index lookups. 我建议阅读http://developer.marklogic.com/try/ninja/page8来了解各种查询选项,并阅读http://docs.marklogic.com/guide/search-dev/count_estimate来了解索引查找。

Adding punctuation automatically makes that term punctuation-sensitive: http://docs.marklogic.com/cts:word-query explains this. 自动添加标点符号使该术语对标点符号敏感: http : //docs.marklogic.com/cts :word- query对此进行了说明。 But the search total will still show the punctuation-insensitive estimate, because the indexes are punctuation-insensitive. 但是搜索总数仍将显示不涉及标点符号的估计,因为索引不涉及标点符号。

This will force a match on the exclamation (or any punctuation): 这将强制在感叹号(或任何标点符号)上进行匹配:

<term>
  <term-option>punctuation-sensitive</term-option>
</term>

I would also recommend using a punctuation-sensitive collation ( http://marklogic.com/collation//S4 ) in your configuration for the range index used for that constraint. 我还建议您在配置中使用对标点敏感的排序规则( http://marklogic.com/collation//S4 ),以用于该约束的范围索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM