-
Introduction
- 入门
- 分布式集群
- 数据
- 分布式增删改查
- 搜索
- 映射和分析
- 结构化查询
- 排序
- 分布式搜索
- 索引管理
- 深入分片
- 结构化搜索
- 全文搜索
- 多字段搜索
- 模糊匹配
- Partial_Matching
- Relevance
- Language intro
- Identifying words
- Token normalization
- Stemming
- Stopwords
- Synonyms
- Fuzzy matching
-
Aggregations
-
overview
-
circuit breaker fd settings
-
filtering
-
facets
-
docvalues
-
eager
-
breadth vs depth
-
Conclusion
-
concepts buckets
-
basic example
-
add metric
-
nested bucket
-
extra metrics
-
bucket metric list
-
histogram
-
date histogram
-
scope
-
filtering
-
sorting ordering
-
approx intro
-
cardinality
-
percentiles
-
sigterms intro
-
sigterms
-
fielddata
-
analyzed vs not
-
overview
- 地理坐标点
- Geohashe
- 地理位置聚合
- 地理形状
- 关系
- 嵌套
- Parent Child
- Scaling
- Cluster Admin
- Deployment
- Post Deployment
元数据:_all 字段
在【简单搜索】中,我们介绍了 _all
字段:一个所有其他字段值的特殊字符串字段。query_string
在没有指定字段时默认用 _all
字段查询。
_all
字段在新应用的探索阶段比较管用,当你还不清楚最终文档的结构时,可以将任何查询用于这个字段,就有机会得到你想要的文档:
GET /_search
{
"match": {
"_all": "john smith marketing"
}
}
copy
随着你应用的发展,搜索需求会变得更加精准。你会越来越少的使用 _all
字段。_all
是一种简单粗暴的搜索方式。通过查询独立的字段,你能更灵活,强大和精准的控制搜索结果,提高相关性。
提示
【相关性算法】考虑的一个最重要的原则是字段的长度:字段越短,就越重要。在较短的 title
字段中的短语会比较长的 content
字段中的短语显得更重要。而字段间的这种差异在 _all
字段中就不会出现
如果你决定不再使用 _all
字段,你可以通过下面的映射禁用它:
PUT /my_index/_mapping/my_type
{
"my_type": {
"_all": { "enabled": false }
}
}
copy
通过 include_in_all
选项可以控制字段是否要被包含在 _all
字段中,默认值是 true
。在一个对象上设置 include_in_all
可以修改这个对象所有字段的默认行为。
你可能想要保留 _all
字段来查询所有特定的全文字段,例如 title
, overview
, summary
和 tags
。相对于完全禁用 _all
字段,你可以先默认禁用 include_in_all
选项,而选定字段上启用 include_in_all
。
PUT /my_index/my_type/_mapping
{
"my_type": {
"include_in_all": false,
"properties": {
"title": {
"type": "string",
"include_in_all": true
},
...
}
}
}
copy
谨记 _all
字段仅仅是一个经过分析的 string
字段。它使用默认的分析器来分析它的值,而不管这值本来所在的字段指定的分析器。而且像所有 string
类型字段一样,你可以配置 _all
字段使用的分析器:
PUT /my_index/my_type/_mapping
{
"my_type": {
"_all": { "analyzer": "whitespace" }
}
}
copy