# Spring-data-aerospike incompatibility

**URL:** https://discuss.aerospike.com/t/spring-data-aerospike-incompatibility/3053
**Category:** Java Client
**Tags:** index, java, spring
**Created:** [June 10, 2016, 3:09pm UTC](https://discuss.aerospike.com/t/spring-data-aerospike-incompatibility/3053 "2016-06-10T15:09:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mustafa-zidan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/mustafa-zidan/32/556_2.png) [@mustafa-zidan](https://discuss.aerospike.com/u/mustafa-zidan)
#### Post date: [June 10, 2016, 3:09pm UTC](https://discuss.aerospike.com/t/spring-data-aerospike-incompatibility/3053/1 "2016-06-10T15:09:48Z")

</div>

I have aerospike server v 3.8.3 installed on my machine and I tried to create an index using the following command in aql:

```auto
aql> CREATE INDEX indexA ON namespace.setA(binA) STRING 

```

Here is the result of `aql> show indexes` command

```auto
+----------------+--------+------------+---------+-------+--------------+--------------+-------------+------------+
| ns | bin | indextype | set | state | indexname | path | sync_state | type |
+----------------+--------+------------+---------+-------+--------------+--------------+-------------+------------+
| "namespace" | "binA" | "NONE" | "setA" | "RW" | "indexA" | "BinB" | "synced" | "STRING" |
+----------------+--------+------------+---------+-------+--------------+--------------+-------------+------------+

```

spring-data-aerospike is expecting the index to be constructed with the following bins

```auto
+----------------+-----------------+--------+----------+-------+-----------+------------+--------------+
| ns | bins | set | num_bins | state | indexname | sync_state | type |
+----------------+-----------------+--------+----------+-------+-----------+------------+--------------+
| "user_profile" | "last_activity" | "west" | 1 | "WO" | "ix1" | "synced" | "INT SIGNED" |
+----------------+-----------------+--------+----------+-------+-----------+------------+--------------

```

the two formats are mentioned in the docs [here](http://www.aerospike.com/docs/guide/query.html) and [here](http://www.aerospike.com/docs/tools/aql/index_management.html)

why there is an incompatibility in the index creation and should I fix the spring-data-aerospike or fix the indices to match the expected output in spring-data-aerospike

com/aerospike/helper/model/Index.java

```auto
/* 
 * Copyright 2012-2015 Aerospike, Inc.
 *
 * Portions may be licensed to Aerospike, Inc. under one or more contributor
 * license agreements.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.aerospike.helper.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.aerospike.client.query.IndexType;
/**
 * This class represents a Secondary Index
 * created in the cluster.
 * 
 * @author peter
 *
 */
public class Index {

	protected Map<String, String> values;
	public Index(String info) {
		setIndexInfo(info);

	}
	public String getName() {
		return values.get("indexname");

	}

	public List<NameValuePair> getValues(){
		List<NameValuePair> result = new ArrayList<NameValuePair>();
		Set<String> keys = this.values.keySet();
		for (String key : keys){
			NameValuePair nvp = new NameValuePair(this, key, this.values.get(key));
			result.add(nvp);
		}
		return result;
	}

	public void setIndexInfo(String info){
		//ns=phobos_sindex:set=longevity:indexname=str_100_idx:num_bins=1:bins=str_100_bin:type=TEXT:sync_state=synced:state=RW;
		if (!info.isEmpty()){
			String[] parts = info.split(":");
			if (values == null){
				values = new HashMap<String, String>();
			}
			for (String part : parts){
				kvPut(part, this.values);
			}
		}
	}
	private void kvPut(String kv, Map<String, String> map){
		String[] kvParts = kv.split("=");
		map.put(kvParts[0], kvParts[1]);
	};

	@Override
	public String toString() {
		return this.getName();
	}
	public String getBin() {
		return values.get("bins");
	}
	public IndexType getType(){
		String indexTypeString = values.get("type");
		if (indexTypeString.equalsIgnoreCase("TEXT"))
			return IndexType.STRING;
		else
			return IndexType.NUMERIC;
	}
}

```

---

<div class="post-metadata">

### Author: ![wchu](https://avatars.discourse-cdn.com/v4/letter/w/a5b964/32.png) [@wchu](https://discuss.aerospike.com/u/wchu)
#### Post date: [June 10, 2016, 9:31pm UTC](https://discuss.aerospike.com/t/spring-data-aerospike-incompatibility/3053/2 "2016-06-10T21:31:12Z")

</div>

Thanks for drawing our attention to this.

The [aerospike-spring-data](https://github.com/spring-projects/spring-data-aerospike) should be updated from “text” to “string”

Appreciate a pull-request to make the correction.

Thanks!

---

<div class="post-metadata">

### Author: ![mustafa-zidan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/mustafa-zidan/32/556_2.png) [@mustafa-zidan](https://discuss.aerospike.com/u/mustafa-zidan)
#### Post date: [June 22, 2016, 11:53am UTC](https://discuss.aerospike.com/t/spring-data-aerospike-incompatibility/3053/3 "2016-06-22T11:53:15Z")

</div>

I’ve done a lot of changes to make the repo fit our needs in the company

1. Fix the index information retrieval incompatibility
2. Add support to EnumToString and StringToEnum Converters
3. Add support to LocalDateTimeToString and StringToLocalDateTime Converters
4. Add support to ZonedDateTimeToString and StringToZonedDateTime Converters
5. Honor [@Document](https://github.com/mustafa-zidan/spring-data-aerospike/blob/master/src/main/java/org/springframework/data/aerospike/mapping/Document.java) annotation collection property.

You can find all the changes [here](https://github.com/mustafa-zidan/spring-data-aerospike) and it passes all the test cases too but I feel this is heavily crafted to our need and not Generic anymore

---

<div class="post-metadata">

### Author: ![wchu](https://avatars.discourse-cdn.com/v4/letter/w/a5b964/32.png) [@wchu](https://discuss.aerospike.com/u/wchu)
#### Post date: [June 22, 2016, 4:43pm UTC](https://discuss.aerospike.com/t/spring-data-aerospike-incompatibility/3053/4 "2016-06-22T16:43:26Z")

</div>

Thanks will take a look.
