# Unable to index documents

**URL:** <https://discuss.elastic.co/t/unable-to-index-documents/200442>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [September 20, 2019, 2:23pm UTC](https://discuss.elastic.co/t/unable-to-index-documents/200442 "2019-09-20T14:23:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mc1392](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mc1392](https://discuss.elastic.co/u/mc1392)\
**Post date:** [September 20, 2019, 2:23pm UTC](https://discuss.elastic.co/t/unable-to-index-documents/200442/1 "2019-09-20T14:23:14Z")

</div>

I'm using Java to push data into Swiftype App Search.  
The logs have 200 has the response, but when I investigate the error message is:

Here is the request body:

```auto
[
  {
    "fileExtension": "jpg",
    "id": 21
  }
]

```

Here is the response in the logs:

```
[
  {
    "id": "21",
    "errors": [
      "Fields can only contain lowercase letters, numbers, and underscores: fileExtension."
    ]
  }
]

```

I decided to send less fields, to help minimize the potential culprits. Just sending 2 fields, **id** and **fileExtension** , that data is all text, not funny characters or anything.

Why am I getting this error when I am indexing simple text?

This code here, I create Maps of data to send to Swiftype:

```
public static <T> List<Map<String, Object>> buildData(List<T> items) {

List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
    for (Iterator<T> it = items.iterator(); it.hasNext();) {
    	HashMap<String, Object> fieldMap = new HashMap<String, Object>();
    	Object o = it.next();

    	Field[] f = o.getClass().getDeclaredFields();

    	for (int i = 0; i < f.length; i++) {

    		f[i].setAccessible(true);

    		String name = f[i].getName();
    		System.out.println(name);
    		Object value = null;
    		try {
    			value = f[i].get(o);
    		} catch (IllegalArgumentException | IllegalAccessException e) {

    			e.printStackTrace();

    		}

    			ieldMap.put(name, value);
    			}

    			data.add(fieldMap);

    		}
    		return data;
    	}

```

And this code here, is how I actually send the data to Swiftype:

```
Client client = new Client(host, privateKey);
        		try {
        			client.indexDocuments(engineName, data);
        		} catch (ClientException e) {
        			e.printStackTrace();
        		}

```

---

<div class="post-metadata">

**Author:** ![orhantoy](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@orhantoy](https://discuss.elastic.co/u/orhantoy)\
**Post date:** [September 20, 2019, 2:28pm UTC](https://discuss.elastic.co/t/unable-to-index-documents/200442/2 "2019-09-20T14:28:20Z")

</div>

Hey @mc1392 👋

`fileExtension` is invalid because of the capital `E`. Try using `file_extension` instead.

---

<div class="post-metadata">

**Author:** ![mc1392](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mc1392](https://discuss.elastic.co/u/mc1392)\
**Post date:** [September 20, 2019, 2:44pm UTC](https://discuss.elastic.co/t/unable-to-index-documents/200442/3 "2019-09-20T14:44:05Z")

</div>

holy cow!

I must be exhausted, because that never crossed my mind.

thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 18, 2019, 2:44pm UTC](https://discuss.elastic.co/t/unable-to-index-documents/200442/4 "2019-10-18T14:44:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
