runSearch method
Implementation
Future<Map> runSearch(String query) async {
if (query != "") {
fieldValue = query;
_animationController.repeat();
_controller = TextEditingController(text: query);
final List corpusKey = [];
for (int i = 0; i < corpusId.length; i++) {
corpusKey.add({"customer_id": customerId, "corpus_id": corpusId[i]});
}
final uri = Uri.parse("https://h.serving.zir.dev:443/v1/query");
final body = jsonEncode({
"query": [
{
"query": query,
"num_results": results,
"corpus_key": corpusKey,
"start": offset
}
]
});
final reply = await http.post(uri,
headers: {
"Content-Type": "application/json",
"x-api-key": apiKey,
"customer-id": customerId,
},
body: body);
_animationController.reset();
Map res = jsonDecode(reply.body)['responseSet'][0];
setState(() {
length = res['response'].length;
});
return res;
}
return new Map();
}