README.md in aliyun_open_search-0.4.0 vs README.md in aliyun_open_search-0.5.0

- old
+ new

@@ -63,10 +63,16 @@ "fields": { "id": "1211391233136", "styl_name": "baoma", "acquirer_id": "1" } + }, + { + "cmd": "delete", + "fields": { + "id": "3" + } } ] } response = AliyunOpenSearch::Syncs.new(app_name).execute(params) @@ -88,10 +94,11 @@ formula: "second_bbs", summary: "summary_snipped:1,summary_field:title,summary_element:high,summary_len:32,summary_ellipsis:...;summary_snipped:2,summary_field:body,summary_element:high,summary_len:60,summary_ellipsis:..." } # 更多例子 +# 1. # params = { # query: [ # [ # "query=default:'#{value}'", # "cars_company_id:'#{value}'", @@ -105,10 +112,29 @@ # "config=start:#{page},hit:#{params[:per_page]}" # ], # fetch_fields: :id # } +# 2. +# start = per_page * (current_page - 1) +# query = [ +# "default:'#{@value}'", +# "configuration:'#{@value}'", +# "user_info:'#{@value}'", +# "authority_roles:'#{@value}'" +# ].join(" OR ") + +# query = "query=(" + query + ") AND cars_company_id:'#{@company_id}'" + +# params = { +# query: [ +# query, +# "config=start:#{start},hit:#{@per_page}" +# ], +# fetch_fields: :id +# } + AliyunOpenSearch::Search.new("test", "test2", "test3").execute(params) ``` ### 签名 @@ -134,13 +160,44 @@ } ].to_json } AliyunOpenSearch::Base.signature( - AliyunOpenSearch::Base.new.basic_params.merge!(custom_params) + AliyunOpenSearch::Base.basic_params.merge!(custom_params) ) ``` + +### 检索 + +```ruby +require "aliyun_open_search" + +scan_service = AliyunOpenSearch::Scan.new("test") +scan_service = AliyunOpenSearch::Scan.new(["test", "test2"]) + +# AliyunOpenSearch::Scan.new( +# ["test", "test2"], + +# 配置: +# query: "query=default:'abc'", # 默认所有 +# hit: "400", # 默认500, 范围 0~500 +# scroll: "1w", +# # 用来表示scroll请求的有效期,默认时间单位为ms, 也可以用1m表示1min +# # 支持的时间单位包括:w=Week, d=Day, h=Hour, m=minute, s=second +# format: "xml" # 默认 JSON +# ) + +scan_service.execute # 获取第一页 +scan_service.result # 获取结果 + +# 下一页 +scan_service.execute # 获取第二页 +scan_service.result # 获取结果 + + +``` + ### 测试 ##### 大部分时候, 我们并不需要真正的发出请求, 需要mock掉 ```ruby