0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS SDK for .NET で CloudSearch から検索してみる

Posted at

準備

検索対象となるデータソースの登録をAWSコンソール上から行う
http://dev.classmethod.jp/cloud/aws/amazon-cloudsearch-japanese-text/

AWS SDK for .NET のインストール

Visual Studio の「NuGetパッケージの管理」からインストールする。
awssdk.png

実装

using Amazon.CloudSearchDomain;
using Amazon.CloudSearchDomain.Model;

public class CloudSearchClient
{
    private readonly AmazonCloudSearchDomainClient cloudSearchDomainClient;

    public CloudSearchClient(string awsAccessKeyId, string awsSecretAccessKey, string serviceUrl)
    {
        cloudSearchDomainClient = 
            new AmazonCloudSearchDomainClient(awsAccessKeyId, awsSecretAccessKey, serviceUrl);
    }

    public long CountSearchResult(string query)
    {
        var request = new SearchRequest
        {
            Query = query
        };

        SearchResponse response = cloudSearchDomainClient.Search(request);
        return response.Hits.Found;
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?