与搜索混淆:建议
我无法借助 search:suggest 函数提供这个简单的自动完成功能。
基于 Marklogic 演示数据中的奥斯卡语料库,我尝试提供一个建议查询,例如,即使用户当前正在写入“Robert Lo”或“Loggia Rob”甚至“,也能够返回“Robert Loggia”作为答案。 L·罗布”。
目前,我只能通过这个简单的查询在他的一些同行中返回“Robert Loggia”:
let $options :=
<options xmlns="http://marklogic.com/appservices/search">
<default-suggestion-source>
<range type="xs:string">
<element ns="http://marklogic.com/wikipedia" name="name" />
</range>
</default-suggestion-source>
</options>
return search:suggest("Rob",$options)
但是一旦我写了一个两个词的短语,我不确定如何写它,因为没有人知道答案与我正在等待的内容是正确的。例如:
search:suggest("Robert Lo",$options)
或者
search:suggest(("Robert", "Lo"),$options)
是否由于缺少选项、索引配置错误或误用功能而导致?
感谢您的帮助
I'm not able to provided this simple autocompletion feature with the help of the search:suggest function.
Based on the Oscars corpus from Marklogic Demo data, I try to provide a suggest query which was for instance able to return "Robert Loggia" as an answer even if the user is currently writing "Robert Lo" or "Loggia Rob" or even "L Rob".
Currently, I'm only able to return "Robert Loggia" amongst some of his peers with this simple query :
let $options :=
<options xmlns="http://marklogic.com/appservices/search">
<default-suggestion-source>
<range type="xs:string">
<element ns="http://marklogic.com/wikipedia" name="name" />
</range>
</default-suggestion-source>
</options>
return search:suggest("Rob",$options)
But as soon as I'm writing a two words phrase, I'm not sure to understand how to write that, because none of the answer is correct with what I'm waiting. For instance :
search:suggest("Robert Lo",$options)
or
search:suggest(("Robert", "Lo"),$options)
Is it due to missing option, indexes misconfiguration or a misused feature ?
Thanks For Help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它具有语法意识。
如果您想获得有关该短语的建议,则需要在该短语周围添加引号,否则它将单独处理标记。请尝试以下操作:
It's
grammar-aware
.You need to add quotes around the phrase if you want to get suggestions on the phrase, otherwise it treats the tokens separately. Try the following:
这是一个常见的错误,我自己也犯过好几次。
正如科琳所说,您需要在查询字符串两边加上引号。这与一般使用搜索 API 或 google 进行搜索相同:带引号的参数被视为一个短语,没有每个标记的都是一个单独的参数。
如果没有引号,默认行为是将这两个术语视为单独的标记,并在查询中对它们进行 AND 或 OR 运算,具体取决于您的配置。
That's a common mistake, I've made it several times myself.
As Colleen says, you need to place quotes around the query string. This is the same as searching in general using the search API, or google for that matter: with quotes your argument is considered a phrase, and without each token is a separate argument.
Without the quotes, the default behavior is to consider the two terms as separate tokens, and to either AND or OR them together in the query, depending on your configuration.
在 OS X 上使用 4.2-6 对我来说也很奇怪。这是我的测试结果,使用完整的奥斯卡数据集。
看起来这些值是为 or-query(('Robert', 'Lo')) 生成的,然后以奇怪的方式合并。如果我们直接使用 cts lexicon 函数,事情看起来很正常。
单词交换方面使事情变得更加复杂,并且超出了自动建议通常所做的范围(以及
search:suggest
和cts:element-value-match
可以做的事情没有帮助)。这是一个使用额外的字符串操作来创建两个模式,处理单词对的版本。它假设第一个单词始终是完整的,而第二个单词可能是存根,但可能需要交换这些单词以进行匹配。如果您定义了所需的逻辑,您应该能够对其进行修改以满足您的要求。请注意,函数映射正在发挥作用,因此在评估期间每个模式都会调用一次
cts:element-value-match
。这可能会对性能产生影响。It looks odd to me too, using 4.2-6 on OS X. Here's what the results looked like in my test, using the full oscars data set.
It looks like the values are generated for or-query(('Robert', 'Lo')) and then merged in an odd way. If we drop down to using the cts lexicon function, things look normal.
The word-swap aspect makes things more complicated, and goes beyond the scope of what autosuggest usually does (and what
search:suggest
andcts:element-value-match
can do without help).Here's a version that uses extra string manipulation to create two patterns, handling pairs of words. It assumes that the first word is always complete, while the second might be a stub, but that the words may need to be swapped for a match. If you define your desired logic, you should be able to modify this to suit your requirements. Note that function mapping is in play, so
cts:element-value-match
is called once per pattern during evaluation. That may have a performance impact.