Unable to index documents

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:

[
  {
    "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();
        		}

Hey @mc1392 :wave:

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

holy cow!

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

thank you!

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