Error Code 204: Index error in small geo test program [SOLVED]




I am trying a small query on geo data with my test installation (Ubuntu 3.7.3)

package de.schrell.aerospike.aerotest;

import com.aerospike.client.AerospikeClient;
import com.aerospike.client.AerospikeException;
import com.aerospike.client.Bin;
import com.aerospike.client.Key;
import com.aerospike.client.Record;
import com.aerospike.client.Value.GeoJSONValue;
import com.aerospike.client.policy.Policy;
import com.aerospike.client.policy.WritePolicy;
import com.aerospike.client.query.Filter;
import com.aerospike.client.query.IndexType;
import com.aerospike.client.query.RecordSet;
import com.aerospike.client.query.Statement;
import com.aerospike.client.task.IndexTask;

import java.util.UUID;

 * Hello world!
public class App
    public static void main( final String[] args )

        System.out.println( "Hello Aerospike!" );

        try (final AerospikeClient client = new AerospikeClient("localhost", 3000)) {

            final Key key = new Key("test", "myset", UUID.randomUUID().toString());
            final Bin bin = new Bin("mybin", new GeoJSONValue("{ \"type\": \"Point\", \"coordinates\": [50.0, 50.0] }"));

            client.put(new WritePolicy(), key, bin);

            System.out.println("creating index...");
            System.out.println("created index.");

            final Statement stm = new Statement();
            stm.setFilters(Filter.geoWithinRadius("mybin", 50, 50, 100));

            try (final RecordSet rs = client.query(null, stm)) {
                while ( {
                    final Key k = rs.getKey();
                    System.out.println("KEY: " + k);
                    final Record record = rs.getRecord();
                    System.out.println("REC: " + record);
                    final String geo = record.getGeoJSON("mybin");
                    System.out.println("GEO in Region: " + geo);

                final String geo = client.get(new Policy(), key).getGeoJSON("mybin");
                final GeoJSONValue g = new GeoJSONValue(geo);

                System.out.println("GEO: " + geo);

    // Doesn't complain if index is already there.
    private static void createIndex(final AerospikeClient client) {
        final Policy policy = new Policy();
        policy.timeout = 0; // Do not timeout on index create.
        final String binName   = "mybin";
        final String indexName = "geo";
        try {
            final IndexTask task = client.createIndex(policy, "test", "myset", indexName, binName, IndexType.GEO2DSPHERE);
        } catch (final AerospikeException e) {

at I get an Error:

Hello Aerospike!
creating index...
created index.
Exception in thread "main" com.aerospike.client.AerospikeException: Error Code 204: Index error
	at com.aerospike.client.command.MultiCommand.parseGroup(
	at com.aerospike.client.command.MultiCommand.parseResult(
	at com.aerospike.client.command.SyncCommand.execute(
	at com.aerospike.client.query.QueryExecutor$
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$

I also created the index with aql, but that did not change anything. Also stm.setIndex(“geo”) did not matter.

Any hint, what I am doing wrong?



Hi Andreas, I tried with your sample test, but didn’t see the issue you are seeing. Please let us know which version of server you are using. Also check in server logs what error is logging when you try to create index.



sorry for the late answer. I will have access to my test system this evening again. I used Ubuntu 15.10 as OS and used aerospace in version 3.7.3. The DB ran on the same server as the test program. I did not see any problems in the log during index creation. And when I try to create the index again (aql) I get an error that it is already there.

I will try tonight again an check if I can get further information.

Thanks for your reply!




I did a new test and with DEBUG enabled and filtering the log with some greps I see

Feb 18 2016 20:18:13 GMT: WARNING (geo): ( failed to parse point: failed to parse geojson: 1: invalid token near '0'
Feb 18 2016 20:18:13 GMT: WARNING (geo): (secondary_index.c::2884) failed to parse query GeoJSON
Feb 18 2016 20:18:13 GMT: DEBUG (sindex): (secondary_index.c:as_sindex_range_free:2628) as_sindex_range_free
Feb 18 2016 20:18:13 GMT: DEBUG (query): (thr_query.c:query_setup:2742) Could not instantiate index range metadata... Err, ERR GENERIC
Feb 18 2016 20:18:13 GMT: WARNING (sindex): (secondary_index.c::226) ERR GENERIC -1 Error at base/thr_query.c,2743

So it looks like my JSON point is somehow wrong:

new GeoJSONValue("{ \"type\": \"Point\", \"coordinates\": [50.0, 50] }"));

But I do not see the problem.




found the problem: Looks like the JAVA-Client is “language aware”. I am located in germany. If I set the environment variable LANG=C everything works fine.

So the real problem is, that the json parser scans [ 50, 50] (space is ignored) to [50,50] which is equivalent to [50.50] in other countries. And that would not be a valid point coordinate.

Bug: The pasring og JSON-Data should not obey any language specific number formats.



Thanks for bringing this up. This does seem to be a short-coming of the jasson library which is used. Will look into improvement (AER-4807).



I’m currently unable to reproduce this bug.

I’m using the following code:

		String geopoint =
			"{ \"type\": \"Point\", \"coordinates\": [50,50] }";
		Bin bin3 = new Bin("bin3", Value.getAsGeoJSON(geopoint));

I’m using “export LANG=de_DE.UTF-8” on both the client and the server.

I’m not seeing the “failed to parse geojson: 1: invalid token near ‘0’”.

NOTE - when I send the value “50.50” on purpose the error message I see on the server is: Feb 25 2016 00:36:35 GMT: WARNING (geo): ( failed to parse point: expected 2 coordinates, saw 1

This is different then the message you reported.

Could you provide more specific client-side code which sees this problem? I’d love to fix it!