![](/img/trans.png)
[英]How can I get top 10 results from Elastic search using rest queries with the max hit documents?
[英]How to get documents by using date as the string comparison from elastic search?
我正在調用ElasticSearch
獲取文檔,然后將其加載到 memory 中。我有一個使用DateRange
的以下代碼,它說給我的文檔大於currentDocumentTime
。
ISearchResponse<DataHolder> docManifests = await queryClient.SearchAsync<DataHolder>(search => search
.Index("full_processVersion")
.Type("ProcessVersion")
.Query(query => query
.DateRange(dateRangeQuery => dateRangeQuery
.Field("DocumentCreatedDate")
.GreaterThan(currentDocumentTime.Value))));
現在我在想是否有任何方法可以修改上述查詢,而不是在currentDocumentTime
上使用GreaterThan
查詢 - 我可以說給我所有GreaterThan
或LessThan
currentDocumentTime
的文檔。
基本上想法是進行字符串比較,這意味着給我任何與currentDocumentTime
不匹配的日期的文檔。
例如,如果currentDocumentTime
是10 月 10 日,假設有一些文檔是 10 月 9 日的,所以我也應該能夠得到它。
這有可能做到嗎?
您也可以在日期類型字段上使用term
。 所以,你的 elasticsearch 查詢是這樣的:
{
"query": {
"bool": {
"must_not": [
{
"term": {
"DocumentCreatedDate": "Your Requested time"
}
}
]
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.