Upload
aaron-king
View
295
Download
8
Embed Size (px)
Citation preview
開始前…
使用前要先有服務的URL跟API金錀
服務 URL命名完後不可修改
要指定API版本
一組服務金錀有分為Manger(2組)與Query(50組)
建立Index時column屬性的設定會影響後續查詢
大家都有的限制-Request
Maximum of 16 MB per request
Maximum 8 KB URL length
Maximum 1000 documents per batch of index uploads, merges, or deletes.
Maximum 25 characters of text in Suggest API request, minimum 3 characters
Maximum 32 fields in $orderby clause
Maximum search term size is 32766 bytes (32 KB minute 2 bytes) of UTF-8 encoded text
大家都有的限制-Response
Maximum 1000 documents returned per page of search results
Maximum 10 suggestions returned per Suggest API request
兩種操作
There are two types of actions that can be executed against the Azure Search Service:
• Index Management: This includes administrative tasks that are executed against a search
service or search index.
• Document Actions: These actions query and manage the corpus for a given index
索引 操作
CREATE -> POST /indexes?api-version=2014-07-31-Preview
UPDATE -> PUT /indexes/[index name]?api-version=2014-07-31-Preview
DELETE -> DELETE /indexes/[index name]?api-version=2014-07-31-Preview
GET -> GET /indexes/[index name]?api-version=2014-07-31-Preview
LIST -> GET /indexes?api-version=2014-07-31-Preview
文件 操作
DML -> POST /indexes/[index name]/docs/index?api-version=2014-07-31-Preview
GET -> GET /indexes/[index name]/docs?[query parameters]
Lookup -> GET /indexes/[index name]/docs/[key]?[query parameters]
DML 操作是用JSON欄位 @search.action做定義
"@search.action": "upload (default) | merge | mergeOrUpload | delete"
C# 使用Azure Search
請愛用 HttpClient
Header 一定要有 api-key
搭配HttpRequestMessage送出資料
傳輸的資料內容一定是JSON格式
詳細的範例 : https://azuresearchadventureworksdemo.codeplex.com/
記得用NuGet console更新一下MVC
Update-package -reinstall Microsoft.AspNet.Mvc
Begin…
Need service URL and API Key before start
Cannot rename service name
Requests must include the api-version
One service include two API Key – Manage(2) and Query (50) .
Index column attribute will affect your query
Free trial Limite
Storage limit 50MB
Documents limit 10000
Only 3 index
They don't ensure service usable
Request Limit
Maximum of 16 MB per request
Maximum 8 KB URL length
Maximum 1000 documents per batch of index uploads, merges, or deletes.
Maximum 25 characters of text in Suggest API request, minimum 3 characters
Maximum 32 fields in $orderby clause
Maximum search term size is 32766 bytes (32 KB minute 2 bytes) of UTF-8 encoded text
Response Limit
Maximum 1000 documents returned per page of search results
Maximum 10 suggestions returned per Suggest API request
Two Operating
There are two types of actions that can be executed against the Azure Search Service:
• Index Management: This includes administrative tasks that are executed against a search service or search index.
• Document Actions: These actions query and manage the corpus for a given index
Index
CREATE -> POST /indexes?api-version=2014-07-31-Preview
UPDATE -> PUT /indexes/[index name]?api-version=2014-07-31-Preview
DELETE -> DELETE /indexes/[index name]?api-version=2014-07-31-Preview
GET -> GET /indexes/[index name]?api-version=2014-07-31-Preview
LIST -> GET /indexes?api-version=2014-07-31-Preview
Document
DML -> POST /indexes/[index name]/docs/index?api-version=2014-07-31-Preview
GET -> GET /indexes/[index name]/docs?[query parameters]
Lookup -> GET /indexes/[index name]/docs/[key]?[query parameters]
DML operating is use JSON column @search.action to declare action
"@search.action": "upload (default) | merge | mergeOrUpload | delete"
Service name conventions
Must be between 2 and 15 characters
Must start with a letter or number, followed by zero or more letters, numbers or dashes ('-')
Must be lowercase
Consecutive dashes are not allowed
Second character cannot be a dash
Index name conventions
Must be between 2 and 128 characters total
Must start with a letter or number, followed by zero or more letters, numbers
or dashes ('-')
Must be lowercase
Consecutive dashes are not allowed
Field name conventions
Must be between 1 and 128 characters
Can contain letters, numbers, and underscore ('_')
Must start with a letter
Cannot start with "azureSearch"
Document key naming conventions
Can contain letters, numbers, underscore ('_'), dashes ('-'), or equal sign ('=')
Cannot start with an underscore ('_')
If you use compound keys and need a separator, we recommend using '-', '_',
or '='.
If the keys in your source data contain characters other than the above, we
recommend encoding them using a URL-safe variant of Base64. For example,
in .NET you can use the HttpServerUtility.UrlTokenEncode method for this
purpose.
Cannot contain backslash ('\'), slash ('/'), or dot ('.')
If you use compound keys and need a separator, we recommend using |.
Tips
Increasing queries per second (QPS) or achieving high availability is done by
adding replicas
high availability need last three replicas
Replicas almost used in application
C# Azure Search
Using HttpClient
Header need have api-key
Use HttpRequestMessage send content
Data only use JSON
More example: https://azuresearchadventureworksdemo.codeplex.com/
You may need use NuGet console to updating MVC reference
Update-package -reinstall Microsoft.AspNet.Mvc