lucene queries for design documents with "::" in the id return 400 "no_such_view" responses #143

Closed
moonmaster9000 opened this Issue Nov 23, 2011 · 3 comments

Projects

None yet

2 participants

@moonmaster9000
Contributor

Running CouchBase Server Community Edition on Mac OS X, version 1.1.1.
Running CouchDBLucene on Mac OS X, version 0.8.0 (built today from fresh clone of couchdb-lucene repo)

Steps to reproduce:

~ λ export COUCHBASE="http://localhost:5984"
~ λ curl $COUCHBASE
{"couchdb":"Welcome","version":"1.1.1"}

~ λ curl -X PUT $COUCHBASE/query_test
{"ok":true}

~ λ cat > design_with_colons.js
{
   "_id": "_design/Some::Model",
   "language": "javascript",
   "fulltext": {
       "by_fulltext": {
           "index": "\n                  function(doc) {\n                    var ret = new Document();\n                    function idx(obj) {\n                      for (var key in obj){\n                        switch (typeof obj[key]) {\n                          case 'object':\n                            idx(obj[key]);\n                            break;\n                          case 'function':\n                            break;\n                          default:\n                            ret.add(obj[key]);\n                            break;\n                        }\n                      }\n                    };\n\n                    if (doc['couchrest-type'] == 'Some::Model') {\n                      idx(doc);\n\n                      if (doc._attachments) {\n                        for (var i in doc._attachments) {\n                          ret.attachment('attachment', i);\n                        }\n                      }\n                    }\n                    return ret;\n                  }\n                "
       }
   }
}

~ λ cat > design_without_colons.js
{
   "_id": "_design/SomeModel",
   "language": "javascript",
   "fulltext": {
       "by_fulltext": {
           "index": "\n                  function(doc) {\n                    var ret = new Document();\n                    function idx(obj) {\n                      for (var key in obj){\n                        switch (typeof obj[key]) {\n                          case 'object':\n                            idx(obj[key]);\n                            break;\n                          case 'function':\n                            break;\n                          default:\n                            ret.add(obj[key]);\n                            break;\n                        }\n                      }\n                    };\n\n                    if (doc['couchrest-type'] == 'SomeModel') {\n                      idx(doc);\n\n                      if (doc._attachments) {\n                        for (var i in doc._attachments) {\n                          ret.attachment('attachment', i);\n                        }\n                      }\n                    }\n                    return ret;\n                  }\n                "
       }
   }
}

~ λ curl -X PUT "$COUCHBASE/query_test/_design/Some::Model" -d @design_with_colons.js
{"ok":true,"id":"_design/Some::Model","rev":"1-ea320b040c7f01626e1100d9f6ca8146"}

~ λ curl -X PUT "$COUCHBASE/query_test/_design/SomeModel" -d @design_without_colons.js
{"ok":true,"id":"_design/SomeModel","rev":"1-2462bbb837299ba95a2f02e05abe67fe"}

~ λ curl -H "Content-Type:application/json" $COUCHBASE/query_test/_fti/_design/SomeModel/by_fulltext?q=hi
{"limit":25,"etag":"1258f384d61858a8","fetch_duration":0,"q":"default:hi","search_duration":0,"total_rows":0,"skip":0,"rows":[]}

~ λ curl -H "Content-Type:application/json" "$COUCHBASE/query_test/_fti/_design/Some::Model/by_fulltext?q=hi"
{"reason":"no_such_view","code":400}
Owner
rnewson commented Nov 24, 2011

I can't reproduce this. My ddoc is called _design/cl::test and I can query it directly on 5985 and through couchdb on 5984 in both Chrome and from curl.

Are you sure you have the latest version of the hook script? It was updated back in July to permit colon characters.

Contributor

Really sorry to have wasted your time on this - although I'd upgraded to 0.0.8 (with the latest hook script), I didn't restart couch, so it was still using the old hook script that it had loaded last time it started. #FACEPALM thanks again for your help, and for an amazing product.

Owner
rnewson commented Nov 25, 2011

No problem, thanks for confirming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment