Support JSONP response for the search API alone.

This commit is contained in:
Kishore Nallan 2017-07-06 22:00:23 +05:30
parent be0a222ccb
commit dda3a0a06a
2 changed files with 14 additions and 8 deletions

View File

@ -41,14 +41,15 @@
- ~~Proper pagination~~
- ~~Pagination parameter~~
- ~~Drop collection API~~
- ~~JSONP response~~
- "error":"Not found." is sent when query has no hits
- Number of records in collection
- Use rocksdb batch put for atomic insertion
- Fix API response codes
- When prefix=true, use token_ranking_field for token ordering only for last word
- Query token ids should match query token ordering
- ID should not have "/"
- Group results by field
- Number of records in collection
- Fix API response codes
- JSONP response
- Use rocksdb batch put for atomic insertion
- Handle store-get() not finding a key
- ~~Test for asc/desc upper/lower casing~~
- ~~Test for search without any sort_by given~~

View File

@ -141,6 +141,7 @@ void get_search(http_req & req, http_res & res) {
const char *FACET_BY = "facet_by";
const char *PER_PAGE = "per_page";
const char *PAGE = "page";
const char *CALLBACK = "callback";
if(req.params.count(NUM_TYPOS) == 0) {
req.params[NUM_TYPOS] = "2";
@ -216,13 +217,17 @@ void get_search(http_req & req, http_res & res) {
result["took_ms"] = timeMillis;
const std::string & json_str = result.dump();
//std::cout << "JSON:" << json_str << std::endl;
const std::string & results_json_str = result.dump();
struct rusage r_usage;
getrusage(RUSAGE_SELF,&r_usage);
//std::cout << "Memory usage: " << r_usage.ru_maxrss << std::endl;
res.send_200(json_str);
if(req.params.count(CALLBACK) == 0) {
res.send_200(results_json_str);
} else {
res.send_200(req.params[CALLBACK] + "(" + results_json_str + ");");
}
std::cout << "Time taken: " << timeMillis << "ms" << std::endl;
}