You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by km <sr...@gmail.com> on 2010/02/26 12:48:52 UTC

couchdb-lucene javascript error missing parenthesis

Hi all,

I get a weird error while using couchdb lucene (0.4) with couchdb 0.10.0
I am unable to index a documents in the couch database.
my lucene view file is like this

{
   "_id": "_design/lucene",
   "_rev": "3-26665646212b049662ed2ff34c4319b3",
   "fulltext": {
       "byid": {
           "index": "function(doc){ var rec = new Document(); rec.add(doc);
return rec;}"
       }
   }
}

But couchdb-lucene.log says

 *2010-02-26 20:36:39,913 [couchdb-lucene] ERROR Error updating index.
org.mozilla.javascript.EvaluatorException: missing } after function body
*    at
org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109)
    at
org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:96)
    at org.mozilla.javascript.Parser.addError(Parser.java:146)
    at org.mozilla.javascript.Parser.reportError(Parser.java:160)
    at org.mozilla.javascript.Parser.mustMatchToken(Parser.java:246)
    at org.mozilla.javascript.Parser.function(Parser.java:597)
    at org.mozilla.javascript.Parser.parse(Parser.java:394)
    at org.mozilla.javascript.Parser.parse(Parser.java:338)
    at org.mozilla.javascript.Context.compileImpl(Context.java:2252)
    at org.mozilla.javascript.Context.compileFunction(Context.java:1281)
    at org.mozilla.javascript.Context.compileFunction(Context.java:1270)
    at com.github.rnewson.couchdb.lucene.Rhino.<init>(Rhino.java:82)
    at
com.github.rnewson.couchdb.lucene.Index$Indexer.updateIndex(Index.java:192)
    at com.github.rnewson.couchdb.lucene.Index$Indexer.run(Index.java:87)
    at java.lang.Thread.run(Thread.java:619)

I have checked for any mismatching parentheses in index function - but thats
not the case !
This "missing } after function body" persists even after I set "index" to
an empty anonymous function.

please let me know if i am missing something.

thanks
Krishna

Re: couchdb-lucene javascript error missing parenthesis

Posted by Bruno Ronchetti <br...@mac.com>.
Hi Krishna,

when I run your JSON through a JSON validator (www.jsonlint.com) it says that there is an invalid character between  rec.add(doc);   and   return rec;}".

I would try to get a valid JSON in jsonlint first and then pasting the expression into your view.

Hope this helps.

Regards. Bruno



On 26/feb/2010, at 12.48, km wrote:

> {
>   "_id": "_design/lucene",
>   "_rev": "3-26665646212b049662ed2ff34c4319b3",
>   "fulltext": {
>       "byid": {
>           "index": "function(doc){ var rec = new Document(); rec.add(doc);
> return rec;}"
>       }
>   }
> }