mirror of
https://github.com/typesense/typesense.git
synced 2025-05-21 22:33:27 +08:00
Support JSONP response for the search API alone.
This commit is contained in:
parent
be0a222ccb
commit
dda3a0a06a
9
TODO.md
9
TODO.md
@ -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~~
|
||||
|
13
src/api.cpp
13
src/api.cpp
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user