Skip to content

Examples

Jonathan Monette edited this page May 22, 2013 · 12 revisions

Querying Cloudsearch

Searching your domain

Curl

curl "http://<search.domain.name>/2011-02-01/search?q=hello"

Output:

{
    "hits": {
        "found": 1,
        "hit": [
            {
                "id": "ac905531122b11e2b7f3005056b70026"
            }
        ],
        "start": 0
    },
    "info": {
        "cpu-time-ms": 0,
        "rid": "8a0620f6c72ff3e7cfd8b3da04b06cb57c6c34dcf611364597365c20ce56f10b9c49740924366dfb",
        "time-ms": 2
    },
    "match-expr": "(label 'hello')",
    "rank": "-text_relevance"
}

Thunderhead

public void searchIt() {
    CloudSearchClient cloudSearchClient = CloudSearchClientBuilder.newInstance()
                                                                  .queryHost("<search.domain.name>")
                                                                  .build();              

    CloudSearchRequest cloudSearchRequest = CloudSearchRequest.newInstance()
                                                              .q("hello");

    SearchResponse searchResponse = client.query(cloudSearchRequest);

    System.out.println(searchResponse);
}

Output:

SearchResponse{
    rank=-text_relevance,
    match-expr=(label 'hello'),
    found=SearchHits{
        count=1,
        start=0,
        hits=[
            SearchHit{
                id=ac905531122b11e2b7f3005056b70026,
                return-fields=null
            }
        ]
    },
    info=SearchInfo{
        rid=8a0620f6c72ff3e7cfd8b3da04b06cb5877967207cf0c79424491e3ba45925044aed5c7734fa6cbd,
        time-ms=3,
        cpu-time-ms=0
    }
}
Clone this wiki locally