basho / riak_pb

Riak Protocol Buffers Messages
Apache License 2.0
70 stars 114 forks source link

ProtoBuf response returns incorrect type #196

Closed p11o closed 8 years ago

p11o commented 8 years ago

When getting a search response on a text_tsd field, I am getting a 0 when the expected value is an empty string.

search response when there is an empty string in the text_tsd field

{
"score":1.1388365,
"_yz_rb":"dev-message",
"_yz_rt":"default",
"_yz_rk":"L6XMFEoolh2zvMPpIFoaxizL2qv",
"_yz_id":"1*default*dev-message*L6XMFEoolh2zvMPpIFoaxizL2qv*41",
"text_tsd":0,
}

value in riak kv for L6XMFEoolh2zvMPpIFoaxizL2qv

{
"text_tsd":""
}

Riak 2.1.4 basho-riak-client 2.1.2

lukebakken commented 8 years ago

Hello @mjpuser - please see the following set of commands where I try to reproduce this. The object appears to be indexed correctly in Solr. I recommend double-checking that you are saving the object with the application/json content type. If you are unable to resolve this issue in your environment, please file an issue in the riak-nodejs-client repository and I'll take it from there.

Create search index in Riak using default schema:

$ curl -4vvv -XPUT localhost:8098/search/index/lrb-test
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8098 (#0)
> PUT /search/index/lrb-test HTTP/1.1
> Host: localhost:8098
> User-Agent: curl/7.48.0
> Accept: */*
>
< HTTP/1.1 204 No Content
< Server: MochiWeb/1.1 WebMachine/1.10.8 (that head fake, tho)
< Date: Mon, 16 May 2016 18:20:48 GMT
< Content-Type: application/json
< Content-Length: 0

Verify creation of lrb-test index:

$ curl -4vvv localhost:8098/search/index
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8098 (#0)
> GET /search/index HTTP/1.1
> Host: localhost:8098
> User-Agent: curl/7.48.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: MochiWeb/1.1 WebMachine/1.10.8 (that head fake, tho)
< Date: Mon, 16 May 2016 18:21:30 GMT
< Content-Type: application/json
< Content-Length: 54
<
* Connection #0 to host localhost left intact
[{"name":"lrb-test","n_val":3,"schema":"_yz_default"}]

Create lrb-test-type and associate with lrb-test index:

$ bin/riak-admin bucket-type create lrb-test-type '{"props":{"search_index":"lrb-test"}}'
lrb-test-type created

$ bin/riak-admin bucket-type activate lrb-test-type
lrb-test-type has been activated

Verify lrb-test-type properties:

$ curl -4vvv localhost:8098/types/lrb-test-type/props|jsonpp
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8098 (#0)
> GET /types/lrb-test-type/props HTTP/1.1
> Host: localhost:8098
> User-Agent: curl/7.48.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Vary: Accept-Encoding
< Server: MochiWeb/1.1 WebMachine/1.10.8 (that head fake, tho)
< Date: Mon, 16 May 2016 18:24:54 GMT
< Content-Type: application/json
< Content-Length: 494
<
{ [494 bytes data]
100   494  100   494    0     0  80930      0 --:--:-- --:--:-- --:--:-- 82333
* Connection #0 to host localhost left intact
{
  "props": {
    "young_vclock": 20,
    "w": "quorum",
    "small_vclock": 50,
    "search_index": "lrb-test",
    "rw": "quorum",
    "r": "quorum",
    "pw": 0,
    "precommit": [],
    "pr": 0,
    "postcommit": [],
    "old_vclock": 86400,
    "notfound_ok": true,
    "n_val": 3,
    "linkfun": {
      "mod": "riak_kv_wm_link_walker",
      "fun": "mapreduce_linkfun"
    },
    "last_write_wins": false,
    "dw": "quorum",
    "dvv_enabled": true,
    "chash_keyfun": {
      "mod": "riak_core_util",
      "fun": "chash_std_keyfun"
    },
    "big_vclock": 50,
    "basic_quorum": false,
    "allow_mult": true,
    "active": true,
    "claimant": "dev1@127.0.0.1"
  }
}

Save JSON object and have Riak generate key:

$ curl -4vvv -XPOST -H 'Content-Type: application/json' localhost:8098/types/lrb-test-type/buckets/lrb-test-bucket/keys -d '{"test_tsd":""}'
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8098 (#0)
> POST /types/lrb-test-type/buckets/lrb-test-bucket/keys HTTP/1.1
> Host: localhost:8098
> User-Agent: curl/7.48.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 15
>
* upload completely sent off: 15 out of 15 bytes
< HTTP/1.1 201 Created
< Vary: Accept-Encoding
< Server: MochiWeb/1.1 WebMachine/1.10.8 (that head fake, tho)
< Location: /types/lrb-test-type/buckets/lrb-test-bucket/keys/Mt26ULIlQcXGqriO0gFZXyJPCUc
< Date: Mon, 16 May 2016 18:30:33 GMT
< Content-Type: application/json
< Content-Length: 0
<
* Connection #0 to host localhost left intact

Verify object saved with random key:

$ curl -4vvv localhost:8098/types/lrb-test-type/buckets/lrb-test-bucket/keys/Mt26ULIlQcXGqriO0gFZXyJPCUc
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8098 (#0)
> GET /types/lrb-test-type/buckets/lrb-test-bucket/keys/Mt26ULIlQcXGqriO0gFZXyJPCUc HTTP/1.1
> Host: localhost:8098
> User-Agent: curl/7.48.0
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Riak-Vclock: a85hYGBgzGDKBVI8R4M2cvt/q7FnYFAXzGBKZMxjZTjZu+4CXxYA
< Vary: Accept-Encoding
< Server: MochiWeb/1.1 WebMachine/1.10.8 (that head fake, tho)
< Link: </buckets/lrb-test-bucket>; rel="up"
< Last-Modified: Mon, 16 May 2016 18:30:33 GMT
< ETag: "5sAnqYlAlinTDG3OqhSudw"
< Date: Mon, 16 May 2016 18:31:09 GMT
< Content-Type: application/json
< Content-Length: 15
<
* Connection #0 to host localhost left intact
{"test_tsd":""}

Object appears to be indexed into search correctly:

$ curl 'localhost:8098/search/query/lrb-test?wt=json&q=*:*'|jsonpp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   686  100   686    0     0  26416      0 --:--:-- --:--:-- --:--:-- 27440
{
  "responseHeader": {
    "status": 0,
    "QTime": 19,
    "params": {
      "q": "*:*",
      "shards": "127.0.0.1:10014/internal_solr/lrb-test",
      "127.0.0.1:10014": "(_yz_pn:62 AND (_yz_fpn:62)) OR _yz_pn:61 OR _yz_pn:58 OR _yz_pn:55 OR _yz_pn:52 OR _yz_pn:49 OR _yz_pn:46 OR _yz_pn:43 OR _yz_pn:40 OR _yz_pn:37 OR _yz_pn:34 OR _yz_pn:31 OR _yz_pn:28 OR _yz_pn:25 OR _yz_pn:22 OR _yz_pn:19 OR _yz_pn:16 OR _yz_pn:13 OR _yz_pn:10 OR _yz_pn:7 OR _yz_pn:4 OR _yz_pn:1",
      "wt": "json"
    }
  },
  "response": {
    "numFound": 1,
    "start": 0,
    "maxScore": 1.0,
    "docs": [
      {
        "test_tsd": "",
        "_yz_id": "1*lrb-test-type*lrb-test-bucket*Mt26ULIlQcXGqriO0gFZXyJPCUc*31",
        "_yz_rk": "Mt26ULIlQcXGqriO0gFZXyJPCUc",
        "_yz_rt": "lrb-test-type",
        "_yz_rb": "lrb-test-bucket"
      }
    ]
  }
}