如何在Couchbase中使用SearchQuery /全文搜索按日期类型排序?

时间:2019-03-07 17:18:08

标签: couchbase spring-data-couchbase couchbase-java-api

我已经配置并索引了receiveDate。看起来像我数据库中的receiveDate:“ 2019-02-130 01:01:01 PM”。如何使用日期类型文本或日期类型实例进行排序?

此处是已配置的字段(假设没有错别字)。

personDoc | only index specified fields
a.  name | text | searchable as nameSort | keyword | index | store
b.  name | text | searchable as nameSearch | OCISSearchAnalyzer | index | include in _all field | include term vectors
c.  receivedDate | datetime | index

我要按名称排序,然后按ReceivedDate排序

new SearchQuery(String indexName, AbstractFtsQuery queryPart).fields("nameSort", "receivedDate").sort("nameSort", "receivedDate");

此处全文索引如下:

...
"receivedDate": {
  "dynamic": false,
  "enabled": true,
  "fields": [
    {
      "analyzer": "keyword",
      "include_in_all": false,
      "include_term_vectors": true,
      "index": true,
      "name": "receivedDate",
      "store": false,
      "type": "datetime"
    }
  ]
},
"name": {
  "dynamic": false,
  "enabled": true,
  "fields": [
    {
      "analyzer": "keyword",
      "include_in_all": false,
      "include_term_vectors": false,
      "index": true,
      "name": "nameSort",
      "store": true,
      "type": "text"
    },
    {
      "analyzer": "OCISSearchAnalyzer",
      "include_in_all": true,
      "include_term_vectors": true,
      "index": true,
      "name": "nameSearch",
      "store": false,
      "type": "text"
    }
  ]
}
...

0 个答案:

没有答案