查詢參考資料
Discovery 查詢參數、運算子和聚集的完整清單。 當您使用 Discovery 查詢語言撰寫查詢時,可以參閱此資訊以取得說明。
在 Discovery 使用者介面中,您可以在 Improve and customize 頁面上撰寫和測試 自然語言查詢。
參數說明
使用查詢參數來搜尋集合、識別結果集,以及分析結果集。
| 參數 | 說明 | 範例 |
|---|---|---|
aggregation |
結果集的統計查詢 | aggregation=term(enriched_text.entities.type) |
filter |
針對相符文件進行的未分級查詢語言搜尋。 | filter=bees |
natural_language_query |
針對相符文件進行的分級自然語言搜尋。 | natural_language_query="How do bees fly" |
query |
針對相符文件進行的分級查詢語言搜尋。 | query=bees |
| 參數 | 說明 | 範例 |
|---|---|---|
count |
要傳回的 result 文件數。 |
count=15 |
highlight |
強調顯示查詢相符項 | highlight=true |
offset |
從結果集傳回 result 文件之前要忽略的結果數 |
offset=100 |
return |
要傳回的欄位清單 | return=title,url |
sort |
用來排序結果集的欄位 | sort=enriched_text.sentiment.document.score |
spelling suggestions |
針對自然語言查詢傳回的拼字建議 | spelling_suggestions=true |
查詢限制
您無法查詢包含下列字元的欄位名稱:
- 欄位名稱字尾中的數字 (
0 - 9)。 例如,extracted-content2。 field_name前綴中的字元_,+,和-。 例如,+extracted-content。field_name中的字元.、,和:。 例如,new:extracted-content。
運算子
運算子是在查詢的不同部分之間的分隔字元。 下表列出了可用的操作符。
| 運算子 | 說明 | 範例 |
|---|---|---|
. |
JSON 定界字元 | enriched_text.concepts.text |
: |
包括 | text:computer |
:: |
完全相符 | title::"Query building" |
:! |
不包含 | text:!computer |
::! |
不完全相符 | text::!winter |
\ |
跳出字元 | title::"Dorothy said: \"There's no place like home.\"" |
"" |
詞組查詢 | enriched_text.concepts.text:"IBM Watson" |
(), [] |
巢狀群組 | filter-entities:(text:Turkey,type:Location) |
| | | 或者 | query-enriched.entities.text:Google|IBM |
, |
和 | query-enriched.entities.text:Google,IBM |
<=, >=, >, < |
數值比較 | enriched_text.sentiment.document.score>0.679 |
^x |
評分乘數 | text:IBM^3 |
* |
萬用字元 | query-enriched_text.concepts.text:pre* |
~n |
字串變異 | query-enriched_text.entities.text:cat~1 |
:* |
存在 | title:* |
!* |
不存在 | title!* |
聚集
聚集傳回一組資料值。 下表列出可用的聚集。
| 聚集 | 說明 | 範例 |
|---|---|---|
average |
結果集內所指定欄位的平均值。 | average(product.price) |
filter |
根據指定的型樣過濾結果 | filter(enriched_text.concepts.text:cloud computing) |
histogram |
間隔型分佈 | histogram(product.price,interval:1) |
max |
結果集內所指定欄位的最大值。 | max(product.price) |
min |
結果集內所指定欄位的最小值。 | min(product.price) |
nested |
限制聚集 | nested(enriched_text.entities) |
sum |
結果集內所有欄位的總和。 | sum(product.price) |
term |
相同值計數 | term(enriched_text.concepts.text,count:10) |
timeslice |
時間型分佈 | timeslice(last_modified,2day,America/New York) |
top_hits |
現行聚集的排名最前結果文件 | term(enriched_text.concepts.text).top_hits(10) |
unique_count |
聚集內欄位的唯一值計數 | unique_count(enriched_text.entities.type) |