Cloudsearch日期范围
问题描述:
我使用以下格式的云搜索文档,并使用简单的queryParser。所以,当我搜索'abc'时,我得到两个结果,因为两个文档包含名字为“abc”。我如何将它带到下一个级别并向查询添加日期范围?类似的,我想在两个日期之间搜索“abc”,其中开始> = date1并开始< date2。我能想到的一种方法是在上传文档之前,将开始的字段转换为timeinMillis,然后执行一个范围。这是唯一的方法来解决这个问题,或我可以建立日期的范围?Cloudsearch日期范围
{
"id": "d48810e8-082a-4422-887c-a3a69aa95f3e",
"fields": {
"origin": [
"http://localhost:3006"
],
"firstname": [
"abc"
],
"started": [
"2017-03-30T15:45:03.848Z"
],
"lastname": [
"xyz"
]
}
},
{
"id": "47ae007e-41ec-4110-82f1-716d4e48670c",
"fields": {
"origin": [
"http://localhost:3006"
],
"firstname": [
"opq"
],
"lastname": [
"rst"
],
"started": [
"2017-01-09T20:00:47.264Z"
]
}
},
{
"id": "6a6df5be-9518-44f4-8b9d-62ff21c5e89c",
"fields": {
"origin": [
"http://localhost:3006"
],
"firstname": [
"abc"
],
"lastname": [
"xyz"
],
"started": [
"2017-01-18T19:09:01.318Z"
]
}
}
感谢@alexroussos的响应。唯一的问题是,我想在文档的任何字段中搜索'abc',而不仅仅是名字。由于我现在使用简单的查询解析器,因此我的cloudsearch将返回包含任何值的“abc”的所有文档。 – Rama
然后不要指定该字段。来自'q.options'的文档:_如果在搜索中没有指定字段并且未指定此选项,则会搜索所有静态配置的文本和文本数组字段._ http://docs.aws.amazon.com/ cloudsearch/latest/developerguide/search-api.html – alexroussos
听起来很不错。谢谢你的帮助。 – Rama