【问题标题】:Need help in creating date range query format sample in QBE(Query by Example) MarkLogic在 QBE(Query by Example) MarkLogic 中创建日期范围查询格式示例需要帮助
【发布时间】:2019-06-04 09:15:13
【问题描述】:

我在 QBE 中寻找日期范围查询。我正在尝试以下查询示例

https://Server:port/v1/qbe?format=json&pageLength=10&start=1&directory=/json/&options=search_option_advanced_date&query={"$query":{
"$and":[{"creation_date":{"$le":"2018-12-12T05:40:47.496"}},{"creation_date":{"$ge":"2017-12-12T05:40:47.496"}}],"$filtered":true}}

在这里,我在“/Creation_Date_date”上创建了路径范围索引,并在“Creation_Date_date”上创建了元素范围索引,还在持久选项的 search_option_advanced_date 文件中添加了以下约束

<constraint name="creation_date">
   <range type="xs:date">
     <element name="Creation_Date_date"/>
   </range>
 </constraint>

虽然应该获取结果,但我得到了以下空白

{
  "snippet-format":"snippet", 
  "total":0, 
  "start":1, 
  "page-length": 10, 
  "selected": "include-with-ancestors", 
  "results":[], 
  "facets": {
    "EntityType":{"type":"xs:string", "facetValues":[]}, 
    "Category":{"type":"xs:string", "facetValues":[]}, 
    "Genre":{"type":"xs:string", "facetValues":[]}, 
    "creation_date":{"type":"xs:date", "facetValues":[]}
  }, 
  "metrics": {
    "query-resolution-time":"PT0.016599S", 
   "facet-resolution-time":"PT0.000578S", 
   "extract-resolution-time":null, "total-time":"PT0.017743S"
  }
}

【问题讨论】:

    标签: javascript rest marklogic date-range query-by-example


    【解决方案1】:

    要使用持久查询选项,QBE 查询必须使用约束属性来指定查询选项:

    http://docs.marklogic.com/guide/search-dev/qbe#id_32338

    也就是说,如果您使用查询选项,则使用组合查询通常更直接:

    http://docs.marklogic.com/guide/rest-dev/search#id_69918

    最后,约束被键入为 xs:date 值,但查询提供 xs:dateTime 值。

    希望对您有所帮助,

    【讨论】:

    • 我会告诉你的。感谢您接受它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-18
    • 1970-01-01
    • 1970-01-01
    • 2021-01-31
    • 1970-01-01
    相关资源
    最近更新 更多