简体   繁体   English

在 Vespa 中使用 userInput 匹配整个短语

[英]Match the whole phrase using userInput in Vespa

Assume that I have two documents with the following content.假设我有两份文件,内容如下。

{
  "title": "Windsor Farmhouse Wood Writing Desk Light Brown - Martin Furniture Furniture"
}

{
  "title": "Benjara 34 in. Rectangular Light Brown/White 1 Drawer Computer Desk, Light Brown & White"
}

The definition of the field is as follows.该字段的定义如下。

field title type string {
  indexing: summary | index | attribute
  index: enable-bm25
}

How can I match only the first document and not the second document when I want to match the phrase desk light in Vespa 8?当我想在 Vespa 8 中匹配短语desk light时,如何只匹配第一个文档而不匹配第二个文档? In other words, I want to match only documents with ... desk light... , but not others like ... desk, light... .换句话说,我只想匹配具有... desk light...的文档,而不是其他类似... desk, light...的文档。

I tried the following query, but it seems like a weakAnd operation in Vespa 8 and matches both documents.我尝试了以下查询,但它似乎是 Vespa 8 中的weakAnd操作并且匹配两个文档。 It also matches documents that contain only ... desk... , which should be expected from the weakAnd operation but not my expectation.它还匹配仅包含... desk...的文档,这应该是weakAnd操作所期望的,但不是我的期望。

_desk_light=desk light
yql=select id, title, summaryfeatures from sources * where ([{"defaultIndex": "title"}](userInput(@_desk_light)));

I also tried adding grammar: phrase annotation to the userInput .我还尝试向userInput添加grammar: phrase注释。 Both of the documents are still matched.两个文档仍然匹配。

_desk_light=desk light
yql=select id, title, summaryfeatures from sources * where ([{"defaultIndex": "title", "grammar": "phrase"}](userInput(@_desk_light)));

Really appreciate any advise.非常感谢任何建议。 Thanks!谢谢!

Using grammar: phrase is the right solution if you only want to match the exact phrase "desk light", but in this case you'll still match both documents as they both contain that phrase (commas are ignored).如果您只想匹配确切的短语“desk light”,那么使用grammar: phrase是正确的解决方案,但在这种情况下,您仍然会匹配两个文档,因为它们都包含该短语(忽略逗号)。

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

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