blob: 19083985eb14e80f4ce616d3535b36a13b697b9f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#pragma once
#include <string>
#include <string_view>
#include <unordered_map>
#include <base/types.h>
#include <Poco/Exception.h>
#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPResponse.h>
#include <Poco/Path.h>
#include <Poco/URI.h>
namespace DB
{
struct MeiliSearchConfiguration
{
String key;
String index;
String connection_string;
MeiliSearchConfiguration(const String & url_, const String & index_, const String & key_) : key{key_}, index{index_}
{
connection_string = url_ + "/indexes/" + index_ + "/";
}
};
using MeiliConfig = MeiliSearchConfiguration;
class MeiliSearchConnection
{
public:
explicit MeiliSearchConnection(const MeiliConfig & config);
String searchQuery(const std::unordered_map<String, String> & query_params) const;
String getDocumentsQuery(const std::unordered_map<String, String> & query_params) const;
String updateQuery(std::string_view data) const;
private:
String execPostQuery(const String & url, std::string_view post_fields) const;
String execGetQuery(const String & url, const std::unordered_map<String, String> & query_params) const;
MeiliConfig config;
mutable Poco::Net::HTTPClientSession session;
};
}
|