结构化查询中短语和术语有什么区别?

时间:2016-03-10 08:57:26

标签: amazon-web-services amazon-cloudsearch

phrase查询中termStructured有何不同?

我的CloudSearch域中有这些数据:

{
    "guid": 9,
    "operating_systems": [
        "12345", "123"
    ],
    "manufacturer": "sealand",
    "model": "gaming tree whale plum",
    "identifier": "gaming tree whale plum",
    "type": "computer",
    "created_at": "1982-10-14T14:43:54Z"
}

"model"类型为text"identifier"类型为literal"created_at"类型为date

让我们进行一些查询:

(phrase field=model 'tree whale')                match
(phrase field= identifier 'tree whale')          no match
(phrase 'tree whale')                            match
(phrase field=created_at '1982-10-14T14:43:54Z') match (this shouldn't match according to docs)

(term field=model 'tree whale')                match
(term field= identifier 'tree whale')          no match
(term 'tree whale')                            match
(term field=created_at '1982-10-14T14:43:54Z') match

phraseterm我无法做什么,反之亦然?

2 个答案:

答案 0 :(得分:1)

term VS phrase的语法和用法之间几乎没有区别。但是,处理phrases时的搜索行为可以terms无法自定义,可以用来提高效果:

  • 允许运营商
  • phraseFields
  • phraseSlop

Terms用于匹配文本字段,phrases用于更复杂的搜索。

浏览网络文档,只需阅读所有PDF文件: http://docs.aws.amazon.com/cloudsearch/latest/developerguide/cloudsearch-dg.pdf

答案 1 :(得分:1)

如果有人想知道,事实证明短语搜索与整个短语匹配,而术语搜索匹配可能是短语但可能是在文档周围散布的单词。例如:

文本:

"model": gaming tree whale plum

以下举行:

(phrase field=model 'tree whale')                match
(phrase field=model 'tree plum')                 no match

(term field=model 'tree whale')                  match
(term field=model 'tree plum')                   match