结构化查询中的短语和术语有什么区别?
What is the difference between phrase and term in structured queries?
phrase
和 term
在 Structured
查询中有何不同?
我的 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
有什么我可以用 phrase
做而我不能用 term
做的,反之亦然吗?
term
VS phrase
的语法和用法差别很小。但是,处理 phrases
时的搜索行为可以通过 terms
无法自定义的方式进行自定义,这可用于提高性能:
- 允许的运算符
- 短语字段
- 短语马虎
Terms
用于匹配文本字段,其中 phrases
用于更复杂的搜索。
跳过网络文档,直接阅读所有 PDF:
http://docs.aws.amazon.com/cloudsearch/latest/developerguide/cloudsearch-dg.pdf
如果有人想知道,结果是短语搜索匹配整个短语,而术语搜索匹配可能是短语但可能是散布在文档中的单词的术语。示例:
正文:
"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
phrase
和 term
在 Structured
查询中有何不同?
我的 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
有什么我可以用 phrase
做而我不能用 term
做的,反之亦然吗?
term
VS phrase
的语法和用法差别很小。但是,处理 phrases
时的搜索行为可以通过 terms
无法自定义的方式进行自定义,这可用于提高性能:
- 允许的运算符
- 短语字段
- 短语马虎
Terms
用于匹配文本字段,其中 phrases
用于更复杂的搜索。
跳过网络文档,直接阅读所有 PDF: http://docs.aws.amazon.com/cloudsearch/latest/developerguide/cloudsearch-dg.pdf
如果有人想知道,结果是短语搜索匹配整个短语,而术语搜索匹配可能是短语但可能是散布在文档中的单词的术语。示例:
正文:
"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