neo4j/community — Issue #119: Multiple Autoindex Issues
Author: espeed
Created: 2011-12-07 07:37:59+00:00
State: open

I used the Gremlin extension to create an automatic index via a Gremlin script like this: https://gist.github.com/1440683

However, the index does not show up in the list of indices...

```
$ curl -H Accept:application/json http://localhost:7474/db/data/index/node
{
"testidx2" : {
"template" : "http://localhost:7474/db/data/index/node/testidx2/{key}/{value}",
"_blueprints:type" : "MANUAL",
"provider" : "lucene",
"type" : "exact"
},
"testidx" : {
"template" : "http://localhost:7474/db/data/index/node/testidx/{key}/{value}",
"_blueprints:type" : "MANUAL",
"provider" : "lucene",
"type" : "exact"
},
"people" : {
"template" : "http://localhost:7474/db/data/index/node/people/{key}/{value}",
"_blueprints:type" : "MANUAL",
"provider" : "lucene",
"type" : "exact"
}
```

But when I try to create it again, I get an error saying it's already created:

```bash
POST url: http://localhost:7474/db/data/ext/GremlinPlugin/graphdb/execute_script
POST body: {"script":"import groovy.json.JsonSlurper\ndef slurper = new JsonSlurper()\nkeys = null\nif (keys != null) \n keys = slurper.parseText(keys) \npublic abstract class TestVertex implements Vertex {} \nindex = g.createAutomaticIndex('test_automatic_idxV',TestVertex.class,keys) \n"}

({'status': '200', 'content-length': '101', 'content-encoding': 'UTF-8', 'server': 'Jetty(6.1.25)', 'access-control-allow-origin': '*', 'content-type': 'application/json'}, '"javax.script.ScriptException: java.lang.RuntimeException: Index already exists: test_automatic_idxV"')
```

Also, the return status is 200 even though the ScriptExtension is ruturning a Java RuntimeException:

```
"javax.script.ScriptException: java.lang.RuntimeException: Index already exists: test_automatic_idxV
```

And the return value is not JSON. I have noticed several occurrences of the Gremlin extension not returning JSON and so you have to hack around it. It would be cleaner if all responses were JSON, including "null" and error responses.