Uploaded image for project: 'Couchbase Documentation'
  1. Couchbase Documentation
  2. DOC-3496

[N1QL API] wildcard needs escaping

    XMLWordPrintable

Details

    Description

      the ‘%’ symbol is the escape character in URI’s.  So, when using % as wild card in N1QL query, we need to escape that by replacing it with corresponding ascii code. Following works without changing the header type when I replace the n1ql wildcard ‘%' with  '%25'
       
      couchbases-MacBook-Pro-5:bin varakurprasad$ curl -v http://172.23.99.98:8093/query/service  -d 'statement=SELECT meta().id FROM `travel-sample`  WHERE type = "hotel" and meta().id LIKE $1 &args=["hotel_1002%25"]'

      •   Trying 172.23.99.98...
      • TCP_NODELAY set
      • Connected to 172.23.99.98 (172.23.99.98) port 8093 (#0)

      > POST /query/service HTTP/1.1

      > Host: 172.23.99.98:8093

      > User-Agent: curl/7.51.0

      > Accept: /

      > Content-Length: 115

      > Content-Type: application/x-www-form-urlencoded

      • upload completely sent off: 115 out of 115 bytes

      < HTTP/1.1 200 OK

      < Content-Length: 416

      < Content-Type: application/json; version=1.6.0

      < Date: Thu, 27 Jul 2017 23:09:10 GMT

      {

          "requestID": "0107e744-1555-48d7-82ba-f76de100ba88",

          "signature": {

              "id": "json"

          },

          "results": [

              {

                  "id": "hotel_10025"

              },

              {

                  "id": "hotel_10026"

              }

          ],

          "status": "success",

          "metrics": {

              "elapsedTime": "174.121649ms",

              "executionTime": "173.998826ms",

              "resultCount": 2,

              "resultSize": 86

          }

      }

      Attachments

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

        Activity

          People

            guy.klages Guy Klages (Inactive)
            guy.klages Guy Klages (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty