Giter Site home page Giter Site logo

aliyun-opensearch-.net-sdk's Introduction

Aliyun OpenSearch SDK For Dotnet

Welcome to OpenSearch SDK for Dotnet, this project provides all features of Aliyun opensearch api.

Prepare

1.Before you run the sdk sample, you need to regist an aliyun account and enable your opensearch service 1.You should get your accessKey and accessSecret from yourt aliyun account mangement page, and your opensearch host address from opensearch configuration mangement page

Usage

using System;
using AliCloud.com.API;
using AliCloud.com.API.Builder;

namespace Sample
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            const string client_id = "your access key";
            const string secret_id = "you access secret";

            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("indexName").Query(new Query("Keyword1").And(new Query("keyword2"))).Config(new Config().Format(ReponseFormat.Json));

            var result = search.Search(builder);
            Console.WriteLine(result);

            Console.Read();
        }
    }
}

QueryBuilder

Aliyun openapi provides many options for developer, QueryBuilder uses chain grammar to make you easily build your search options, it contains all Query clause: query,config,filter,distinct,sort,kvpair and aggregate, and it also provides an easy way to set summary option, just enjoy it!

Response data modal

If you like to use strong data modal to access service response result, you can use Utilities.ConvertResult() to convert it.

Data update

For the performance reason, you should submmit your data update operation like add/update/delete in one request:

CloudsearchDoc target = new CloudsearchDoc(IndexName, this.api);
target.Add("[{'id':1,'author':'nathan'}]").Update(...).Delete(...).Push(tableName);

Suggestion

Suggestion api is also very easy, one thing you should know is that its search query is not totally same as search api query, it do not needs index name in here.

var suggest = new CloudsearchSuggest(applicationName, suggestName,api);
string[] suggestions = suggest.GetSuggest(keyword,hit);

Naming Convention

Since aliyun opensearch is a service which updated from another one, so it also keeps some original names which has ambiguity, such as "index". In this SDK, all 'index' means the index meaning, and use 'applicatin' to describe a index container.

CI

Build Status

##License This SDK is distributed under the Apache License 2.0

aliyun-opensearch-.net-sdk's People

Contributors

www avatar xioxu avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.