Giter Club home page Giter Club logo

opensearch-sdk's Introduction

aliyun-opensearch-python-sdk

Welcome to aliyun-opensearch-python-sdk, this sdk provides you with simple and efficient method to use aliyun opensearch service.

created by cicero, [email protected]

Installation

Install this sdk from source code:

python setup.py install

Usage

Please refer to sample.py for general information

Here list some information about query

query

you have three methods to trigger a query

search class could be write as link expression, each clause is a method

client = OpensearchClientFactory.create_client("hangzhou", "external", "accessKeyId", "accessKey") search = Search(self.client)

  1. simple way, you could search.query("default:'阿里巴巴'", "default:'阿里妈妈'").index_name(app_name) it means query=default:'阿里巴巴' AND default:'阿里妈妈'

  2. combination complex query condition using Q search.query(Q(default="title"), Q(default="中文")|Q(default="title3")).rank("校长").index_name(app_name1, app_name2) Please notice index_name is essential, and it supports multi application name :)

    Q is support all operates:

     Q(1) | Q(2) => default:'1' OR default:'2'
     Q(1) & Q(2) => default:'1' AND default:'2'
     Q(a=1), Q(2) | Q(3) => a:'1' AND (default:'2' OR default:'3')
     Q(a=1) & Q(b=2) | Q(c=3) => a:'1' AND b:'2' OR c:'3'
     Q(a=1), ~Q(b=2) => a:'1' ANDNOT b:'2'
    

    if you want to add RANK, rank() method will help you, please refer to test_search.py

  3. too complicated query string... you think class Q can not be used, query_raw() method will help you execute plain query string

config

use config() method, the parameter is refer to http://help.aliyun.com/document_detail/opensearch/api-reference/query-clause/config-clause.html

filter

use filter() method, the filter conditional is a little like query clause, just use FQ to combine complex filter rule

sort

use sort() method

aggregate

use aggregate() method, if you have more than one group parameter, you could call this method multi times, each time add a group parameter. for more parameter information, please refer to http://help.aliyun.com/document_detail/opensearch/api-reference/query-clause/aggregate-clause.html

distinct

use distinct() method, please refer to http://help.aliyun.com/document_detail/opensearch/api-reference/query-clause/distinct-clause.html for parameter's usage

kvpairs

use kvpairs() method

Development

Contributing

Bug reports and pull requests are welcome on GitHub at http://git.oschina.net/cicero-zhao/aliyun-opensearch-python-sdk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

This library is distributed under the Apache License, version 2.0


copyright information: XXXX

licensed under the apache license, version 2.0 (the "license");
you may not use this file except in compliance with the license.
you may obtain a copy of the license at

    http://www.apache.org/licenses/license-2.0

unless required by applicable law or agreed to in writing, software
distributed under the license is distributed on an "as is" basis,
without warranties or conditions of any kind, either express or implied.
see the license for the specific language governing permissions and
limitations under the license.

opensearch-sdk's People

Contributors

rozhao2 avatar

Stargazers

 avatar  avatar Haifeng(海峰) avatar

Watchers

 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.