Amazon Cloudsearch 不使用部分字符串进行搜索
Amazon Cloudsearch not searching with partial string
我正在测试 Amazon Cloudsearch
我的 Web 应用程序,我 运行 遇到了一些奇怪的问题。
我有以下域索引:name
、email
、id
.
例如,我有这样的数据:John Doe、John@example.com、 1
当我搜索 jo
时,我一无所获。如果我搜索 joh
我仍然一无所获,但是如果我搜索 john
然后我会得到上面的文档。为什么当我放置部分字符串时它没有得到?我什至在 name
和 email
上启用了 模糊匹配 的建议。还有什么我想念的吗?我阅读了以下内容:
http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching-text.html
http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching.html
http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching-compound-queries.html
我正在使用 boto 以及 AWS 页面上的表单进行搜索。
您正在尝试做的事情 - 通过搜索 "jo" 找到 "john" - 称为 前缀搜索 。
您可以通过搜索
来完成此操作
(prefix field=name 'jo')
或
q=jo*
请注意,如果您使用 q=jo*
将 * 附加到所有查询的方法,您可能需要执行类似 q=jo* |jo
的操作,因为 john*
将不匹配 john
.
这看起来有点令人困惑,但想象一下如果 google 返回前缀匹配的结果:如果您搜索 tort 并返回关于 tortoises 和 torture 而不是 tort (法律术语),你会很困惑(和沮丧) .
建议者也是一种可行的方法,但它会给您返回建议(例如 john
、jordan
和 jostle
,而不是结果),您随后需要搜索这些建议为了;它不会 return 为您匹配文档。
参见 "Searching for Prefixes in Amazon CloudSearch" http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching-text.html
你的索引字段类型是"Text"吗?如果它们只是 "Literals",则它们必须完全匹配。
我认为您必须将 name
和 email
字段设置为 literal
类型而不是 text
类型,否则 [= 的简单文本搜索24=] 或 'Joh' 应该已经找到示例文档了。
虽然使用前缀搜索可能已经解决了您的问题(如果字段设置为 literal
类型,这是有道理的),但接受的答案并不是 真的 正确。它是 "like a google search" 的概念并非基于文档中的任何内容。它实际上与他们使用的示例相矛盾,并且通常混淆了服务的可能性。来自 docs:
When you search text and text-array fields for individual terms, Amazon CloudSearch finds all documents that contain the search terms anywhere within the specified field, in any order. For example, in the sample movie data, the title field is configured as a text field. If you search the title field for star, you will find all of the movies that contain star anywhere in the title field, such as star, star wars, and a star is born. This differs from searching literal fields, where the field value must be identical to the search string to be considered a match.
我正在测试 Amazon Cloudsearch
我的 Web 应用程序,我 运行 遇到了一些奇怪的问题。
我有以下域索引:name
、email
、id
.
例如,我有这样的数据:John Doe、John@example.com、 1
当我搜索 jo
时,我一无所获。如果我搜索 joh
我仍然一无所获,但是如果我搜索 john
然后我会得到上面的文档。为什么当我放置部分字符串时它没有得到?我什至在 name
和 email
上启用了 模糊匹配 的建议。还有什么我想念的吗?我阅读了以下内容:
http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching-text.html
http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching.html
http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching-compound-queries.html
我正在使用 boto 以及 AWS 页面上的表单进行搜索。
您正在尝试做的事情 - 通过搜索 "jo" 找到 "john" - 称为 前缀搜索 。
您可以通过搜索
来完成此操作(prefix field=name 'jo')
或
q=jo*
请注意,如果您使用 q=jo*
将 * 附加到所有查询的方法,您可能需要执行类似 q=jo* |jo
的操作,因为 john*
将不匹配 john
.
这看起来有点令人困惑,但想象一下如果 google 返回前缀匹配的结果:如果您搜索 tort 并返回关于 tortoises 和 torture 而不是 tort (法律术语),你会很困惑(和沮丧) .
建议者也是一种可行的方法,但它会给您返回建议(例如 john
、jordan
和 jostle
,而不是结果),您随后需要搜索这些建议为了;它不会 return 为您匹配文档。
参见 "Searching for Prefixes in Amazon CloudSearch" http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching-text.html
你的索引字段类型是"Text"吗?如果它们只是 "Literals",则它们必须完全匹配。
我认为您必须将 name
和 email
字段设置为 literal
类型而不是 text
类型,否则 [= 的简单文本搜索24=] 或 'Joh' 应该已经找到示例文档了。
虽然使用前缀搜索可能已经解决了您的问题(如果字段设置为 literal
类型,这是有道理的),但接受的答案并不是 真的 正确。它是 "like a google search" 的概念并非基于文档中的任何内容。它实际上与他们使用的示例相矛盾,并且通常混淆了服务的可能性。来自 docs:
When you search text and text-array fields for individual terms, Amazon CloudSearch finds all documents that contain the search terms anywhere within the specified field, in any order. For example, in the sample movie data, the title field is configured as a text field. If you search the title field for star, you will find all of the movies that contain star anywhere in the title field, such as star, star wars, and a star is born. This differs from searching literal fields, where the field value must be identical to the search string to be considered a match.