Date Range Query in FTS

Hi,

Firstly, thank you for the excellent free training courses of whichI have completed four so far.

I am busy with Course CB121 - Intro to Couchbase Full Text Search (FTS).
In the Lab Workbook, on page 40.

The instruction reads:

B. (Challenge) Configure smallest possible index, and search by date range

  1. You want to search for all orders placed in the first two weeks of February, 2016,
    searching Order documents only. Configure and build the smallest FTS index you can to
    support this search. Then, configure and run the REST query needed to obtain the
    relevant document IDs, only, from the new index.

I continue to get the following output from my query in Postman:

{
    "status": {
        "total": 1,
        "failed": 0,
        "successful": 1
    },
    "request": {
        "query": {
            "start": "2016-02-01T00:00:00Z",
            "end": "2016-02-14T00:00:00Z",
            "inclusive_start": true,
            "inclusive_end": true,
            "field": "order_date"
        },
        "size": 10,
        "from": 0,
        "highlight": {
            "style": null,
            "fields": null
        },
        "fields": [
            "*"
        ],
        "facets": null,
        "explain": false,
        "sort": [
            "-_score"
        ],
        "includeLocations": false,
        "search_after": null,
        "search_before": null
    },
    "hits": [],
    "total_hits": 0,
    "max_score": 0,
    "took": 1000500,
    "facets": null
}

My Index is as follows:

{
  "type": "fulltext-index",
  "name": "cb121_dates",
  "uuid": "76d1384e36535496",
  "sourceType": "couchbase",
  "sourceName": "WineSearch",
  "sourceUUID": "12bac0cbc75c0f1140dfa5aef292c247",
  "planParams": {
    "maxPartitionsPerPIndex": 1024,
    "indexPartitions": 1
  },
  "params": {
    "doc_config": {
      "docid_prefix_delim": "",
      "docid_regexp": "",
      "mode": "type_field",
      "type_field": "type"
    },
    "mapping": {
      "analysis": {
        "date_time_parsers": {
          "WineSearch": {
            "layouts": [
              "\"2016-12-16 00:00:00\""
            ],
            "type": "flexiblego"
          }
        }
      },
      "default_analyzer": "standard",
      "default_datetime_parser": "dateTimeOptional",
      "default_field": "_all",
      "default_mapping": {
        "dynamic": true,
        "enabled": false
      },
      "default_type": "_default",
      "docvalues_dynamic": true,
      "index_dynamic": true,
      "store_dynamic": false,
      "type_field": "_type",
      "types": {
        "order": {
          "dynamic": false,
          "enabled": true,
          "properties": {
            "order_date": {
              "dynamic": false,
              "enabled": true,
              "fields": [
                {
                  "docvalues": true,
                  "include_in_all": true,
                  "include_term_vectors": true,
                  "index": true,
                  "name": "order_date",
                  "store": true,
                  "type": "text"
                }
              ]
            }
          }
        }
      }
    },
    "store": {
      "indexType": "scorch"
    }
  },
  "sourceParams": {}
}

I would appreciate some guidance please as I can’t find a problem with my setup.

I am using couchbase-server-enterprise_6.6.0-windows_amd64.

As can be seen I am using the default datetimeparser.

Many thanks for the assistance,

The index definition looks slightly wrong. You need to use the datetime field type for the order_date field.
Now it incorrectly has chosen like a text type field.

Example:

"order_date": {
            "dynamic": false,
            "enabled": true,
            "fields": [
              {
                "include_term_vectors": true,
                "index": true,
                "name": "order_date",
                "type": "datetime"
              }
            ]
          }

Cheers!

Thank you @sreeks. I sent the incorrect definition in my question. :grinning: I did manage to get the index and query to work but I don’t know what I was doing wrong or what I fixed. I suspect it was the format of my dates in the query.