CouchDBClient find method

Skip to first unread message

Conny Hageluken

Nov 7, 2019, 8:08:08 AM11/7/19
to LightCouch
The CouchdbClient method creates a HTTP get request as far as I can traces.
Source code from CouchdbClientBase
	public <T> T find(Class<T> classType, String id) {
		assertNotEmpty(classType, "Class");
		assertNotEmpty(id, "id");
		final URI uri = buildUri(getDBUri()).pathEncoded(id).build();
		return get(uri, classType);

In the CouchDB documentation you will find the following example
POST /movies/_find HTTP/1.1
Accept: application/json
Content-Type: application/json
Content-Length: 168
Host: localhost:5984

    "selector": {
        "year": {"$gt": 2010}
    "fields": ["_id", "_rev", "year", "title"],
    "sort": [{"year": "asc"}],
    "limit": 2,
    "skip": 0,
    "execution_stats": true
Clearly a POST request. 
I pressume that for that reason find does not work.

Juanjo Rodriguez

Nov 7, 2019, 8:38:01 AM11/7/19
to LightCouch
the find method in LightCouch is not the correct one for your case. You should use findDocs

* Find documents using a declarative JSON querying syntax.
* @param <T> The class type.
* @param jsonQuery The JSON query string.
* @param classOfT The class of type T.
* @return The result of the query as a {@code List<T> }
* @throws CouchDbException If the query failed to execute or the request is invalid.
public <T> List<T> findDocs(String jsonQuery, Class<T> classOfT)
Reply all
Reply to author
0 new messages