0
votes

I am using ektorp 1.4.1 Jar to connect to Cloudant database. Now I am able to write map and reduce functions using class EventRepository extends CouchDbRepositorySupport. But my problem here is, how I can query for Index and Selector using ektorp java API? Please help me out here by any one. Thanks in advance.

This is my Query Index :

{
  "index": {
    "fields": [
      {"name": "userName", "type": "string"}
    ]
  },
  "type": "text"
} 

and here is my selector code for getting all Events from cloudant by User Name Descending order by startDate.

{
  "selector": {
    "userName": "[email protected]" 
  },
  "fields": [
    "userName",
    "startDate",
    "days",
    "_id",
    "_rev"
  ],
  "sort": [
    {
      "userName": "desc"
    }
  ]
} 

I am using the below code to connect cloudant using Cloudant java API...

CloudantClient client = ClientBuilder.url(new URL("https://userName:password@*****.cloudant.com")).username("*******").
password("*******").build();             
List<String> dbsList = client.getAllDbs();
System.out.println("...dbsList size is :: " + dbsList.size());

CloudantClient client = ClientBuilder.account("username").username("username").password("password").
build();

but still same issue... and even I have tried in different way...

... and I am getting below mentioned error while running on Eclipse Websphere server 7.0 on local...

***********Error************* [3/9/16 23:53:43:547 IST] 00000031 SystemErr R com.cloudant.client.org.lightcouch.CouchDbException: 400 Bad request:

400 Bad request

Your browser sent an invalid request. [3/9/16 23:53:43:548 IST] 00000031 SystemErr R at com.cloudant.client.org.lightcouch.CouchDbClient.execute(CouchDbClient.java:501) Plz help me some thing here... Thanks in advance :)
1
What is the full stack trace? Are you using the latest version of the cloudant java library? - rhyshort

1 Answers

0
votes

From my (quick) reading of the ektorp API, it doesn't support Cloudant Query, (the product name for query). However there is a Official Cloudant java library which does support the Cloudant Query endpoints.