private static void Main(string[] args) { const string client_id = "TR2QyWfDusb0Tgce"; const string secret_id = "ZPJZBMEr2pcMP2fsGeHH36PzZeNYHW"; var apiclient = new CloudsearchApi(client_id, secret_id, "http://opensearch-cn-hangzhou.aliyuncs.com"); var search = new CloudsearchSearch(apiclient); var builder = new QueryBuilder(); builder.ApplicationNames("datafiddleSearch") .Query(new Query("云").And(new Query("搜索"))) .Config(new Config().Format(ReponseFormat.Json)); var result = search.Search(builder); Console.WriteLine(result); #if NET45 string asyncResult = null; var t = Task.Run(async() => { asyncResult = await search.SearchAsync(builder); }); t.Wait(); Console.WriteLine(asyncResult); #endif Console.Read(); }
private CloudsearchSearch GetSearchApi() { var _client = new CloudsearchApi(config.AccessKey, config.AccessSecret, config.Host); var search = new CloudsearchSearch(_client); return(search); }
public CloudSearchApiAliyunBase() { const string client_id = "LTAIPjkCtjCZvCIL"; const string secret_id = "giDKCpKxO4Cu6HPLGxOKSD5ubJpsxg "; #if DEBUG api = new CloudsearchApi(client_id, secret_id, "http://opensearch-cn-hangzhou.aliyuncs.com", 1, "HMAC-SHA1", "1.0", 100000); #else api = new CloudsearchApiMock(client_id, secret_id, "http://opensearch-cn-hangzhou.aliyuncs.com", 1, "HMAC-SHA1", "1.0", 100000); #endif mockApi = new CloudsearchApiMock(client_id, secret_id, "http://opensearch.console.aliyun.com/", 1, "HMAC-SHA1", "1.0", 50000, true); }
public CloudSearchApiAliyunBase() { const string client_id = "TR2QyWfDusb0Tgce"; const string secret_id = "ZPJZBMEr2pcMP2fsGeHH36PzZeNYHW "; #if DEBUG api = new CloudsearchApi(client_id, secret_id, "http://opensearch-cn-hangzhou.aliyuncs.com", 1, "HMAC-SHA1", "1.0", 100000); #else api = new CloudsearchApiMock(client_id, secret_id, "http://opensearch-cn-hangzhou.aliyuncs.com", 1, "HMAC-SHA1", "1.0", 100000); #endif mockApi = new CloudsearchApiMock(client_id, secret_id, "http://opensearch.console.aliyun.com/", 1, "HMAC-SHA1", "1.0", 50000, true); }
private CloudsearchDoc GetSearchDocApi() { var _client = new CloudsearchApi(config.AccessKey, config.AccessSecret, config.Host); var indexNames = MapIndexNames(); string idx = string.Empty; if (indexNames != null && indexNames.Length > 0) { idx = indexNames[0]; } if (string.IsNullOrEmpty(idx)) { throw new InvalidOperationException("indexName is required! check your config ,make sure your index name is corrected configed"); } CloudsearchDoc target = new CloudsearchDoc(idx, _client); return(target); }
static void Main(string[] args) { CloudsearchApi MyAPI = null; const String AccessKeyID = ""; const String AccessKeySecret = ""; MyAPI = new CloudsearchApi(AccessKeyID, AccessKeySecret, "http://opensearch-cn-hangzhou.aliyuncs.com/", 1); var IndexName = "dianlv"; var MySearch = new CloudsearchSearch(MyAPI); MySearch.addIndex(IndexName); MySearch.setFormat("json"); MySearch.setHits(10); var SearchKeywords = "美食"; MySearch.setQueryString("config=start:0,hit:10&&query=title:'" + SearchKeywords + "'"); var SearchResult = MySearch.search(); Console.WriteLine(SearchResult); Console.ReadLine(); }
public void ProcessRequest(HttpContext context) { var Keywords = context.Request.QueryString["Keywords"]; CloudsearchApi MyAPI = null; const String AccessKeyID = ""; const String AccessKeySecret = ""; MyAPI = new CloudsearchApi(AccessKeyID, AccessKeySecret, "http://opensearch-cn-hangzhou.aliyuncs.com/", 1); var IndexName = "dianlv"; var MySearch = new CloudsearchSearch(MyAPI); MySearch.addIndex(IndexName); MySearch.setFormat("json"); MySearch.setHits(10); var SearchKeywords = Keywords; MySearch.setQueryString("config=start:0,hit:10&&query=title:'" + SearchKeywords + "'"); var SearchResult = MySearch.search(); context.Response.ContentType = "text/plain"; context.Response.Write(SearchResult); }
private static void Main(string[] args) { const string client_id = "LTAIPjkCtjCZvCIL"; const string secret_id = "giDKCpKxO4Cu6HPLGxOKSD5ubJpsxg"; var apiclient = new CloudsearchApi(client_id, secret_id, "http://opensearch-cn-hangzhou.aliyuncs.com"); var search = new CloudsearchSearch(apiclient); var doc = new CloudsearchDoc("SUSHI_TEST", apiclient); doc.Add() var builder = new QueryBuilder(); builder.ApplicationNames("SUSHI_TEST") .Query(new Query("云").And(new Query("搜索"))) .Config(new Config().Format(ReponseFormat.Json)); var result = search.Search(builder); Console.WriteLine(result); Console.Read(); }