查询参考
Discovery 查询参数、运算符和聚集的完整列表。 使用 Discovery Query Language 编写查询时,可以参考此信息以获取帮助。
在 Discovery 用户界面中,您可以在 “改进和自定义”页面上编写和测试 自然语言查询。
参数描述
使用查询参数来搜索集合,识别结果集以及分析结果集。
参数 | 描述 | 示例 |
---|---|---|
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) |