Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-41604

FTS: search_before/search_after feature fails with numeric data type.

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not a Bug
    • 6.6.0
    • None
    • fts
    • Untriaged
    • Centos 64-bit
    • 1
    • Unknown

    Description

      build: 6.6.0 - 7920

      steps to reproduce:

      • create default bucket
      • load the following documents:

       

        {
          "default": {
            "filler": "filler",
            "num": 1,
            "str": "string_1"
          },
          "id": "doc_1"
        }
        {
          "default": {
            "filler": "filler",
            "num": 2,
            "str": "string_2"
          },
          "id": "doc_2"
        }
      ....
      {
          "default": {
            "filler": "filler",
            "num": 10,
            "str": "string_10"
          },
          "id": "doc_10"
        }

      • create default fts index on default bucket:

       

      {
       "name": "idx1",
       "type": "fulltext-index",
       "params": {
        "doc_config": {
         "docid_prefix_delim": "",
         "docid_regexp": "",
         "mode": "type_field",
         "type_field": "type"
        },
        "mapping": {
         "default_analyzer": "standard",
         "default_datetime_parser": "dateTimeOptional",
         "default_field": "_all",
         "default_mapping": {
          "dynamic": true,
          "enabled": true
         },
         "default_type": "_default",
         "docvalues_dynamic": true,
         "index_dynamic": true,
         "store_dynamic": false,
         "type_field": "_type"
        },
        "store": {
         "indexType": "scorch"
        }
       },
       "sourceType": "couchbase",
       "sourceName": "default",
       "sourceUUID": "25445d2a40758a64bb34564ff9f916eb",
       "sourceParams": {},
       "planParams": {
        "maxPartitionsPerPIndex": 171,
        "indexPartitions": 6,
        "numReplicas": 0
       },
       "uuid": "6e434e3e9afc7bc0"
      }
       

       

       Try to run the following query:

      curl -XPOST -H "Content-Type: application/json" -u <username>:<password> http://<your ip address>:8094/api/index/idx1/query -d '{"explain": false, "fields": ["*"], "highlight": {}, "query": {"query": "filler:filler"},"size": 2, "from":0, "search_before": [5, "doc_5"], "sort": ["num", "_id"]}'
      

      It returns the following error response:

      {
        "error": "rest_index: Query, indexName: idx1, err: bleve: QueryBleve parsing searchRequest, err: cbft.SearchRequest: Sort: []json.RawMessage: SearchBefore: []string: ReadString: expects \" or n, but found 5, error found in #10 byte of ...|efore\": [5, \"doc_5\"]|..., bigger context ...|:filler\"},\"size\": 2, \"from\":0, \"search_before\": [5, \"doc_5\"], \"sort\": [\"num\", \"_id\"]}|...",
        "request": {
          "explain": false,
          "fields": [
            "*"
          ],
          "from": 0,
          "highlight": {},
          "query": {
            "query": "filler:filler"
          },
          "search_before": [
            5,
            "doc_5"
          ],
          "size": 2,
          "sort": [
            "num",
            "_id"
          ]
        },
        "status": "fail"
      }
      

      Key point is: when I'm using any other datatype than string as search_before/search_after parameter, this query fails.

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          My reply via email:

           
          Sort values are always an array of strings, thus the argument for search_before/search_after is also always an array of strings.
           
          If you sort by a numeric column, the sort value returned to you is encoded as a string, not the original numeric value.  It is expect that normal use of this API is by running a search, and using actual sort values from previous results to generate subsequent calls to the API.

          marty.schoch Marty Schoch (Inactive) added a comment - My reply via email:   Sort values are always an array of strings, thus the argument for search_before/search_after is also always an array of strings.   If you sort by a numeric column, the sort value returned to you is encoded as a string, not the original numeric value.  It is expect that normal use of this API is by running a search, and using actual sort values from previous results to generate subsequent calls to the API.
          abhinav Abhinav Dangeti added a comment - - edited

          search_after and search_before within the FTS search request only accept an array of strings.

          abhinav Abhinav Dangeti added a comment - - edited search_after and search_before  within the FTS search request only accept an array of strings.

          People

            evgeny.makarenko Evgeny Makarenko (Inactive)
            evgeny.makarenko Evgeny Makarenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty