执行搜索时,它将广播到全部索引/索引分片(副本之间的循环)。能够经过提供routing
参数来控制将搜索哪些分片。例如,在索引book时,路由值能够是name。html
POST book/english?routing=testgit
{
"name":"test",
"age":"1",
"book":"zhegnsh1正式"
}github
按路由查询:正则表达式
POST book/_search?routing=test
{
"query": { "bool" : { "must" : { "query_string" : { "query" : "good" } }, "filter" : { "term" : { "name" : "test" } } } } }
"query" : "good" 全文搜索模糊匹配,返回任何字段包含"good”的记录。
做为以循环方式发送到数据副本的请求的替代方法,能够启用自适应副本选择。这容许协调节点根据许多标准将请求发送到被认为“最佳”的副本:算法
这能够经过改变所述动态群集配置开启 cluster.routing.use_adaptive_replica_selection
从false
到true
json
PUT /_cluster/settings { "transient": { "cluster.routing.use_adaptive_replica_selection": true } }
搜索能够与统计组相关联,统计组维护每一个组的统计聚合。稍后可使用indices stats API专门检索它 。例如,如下是将请求与两个不一样的组相关联的搜索正文请求:api
POST /_search
{
"query" : { "match_all" : {} }, "stats" : ["group1", "group2"] }
做为请求正文搜索的一部分,单个搜索可能会超时 。因为搜索请求能够源自多个源,所以Elasticsearch具备全局搜索超时的动态集群级设置,适用于未在请求正文搜索中设置超时的全部搜索请求。默认值为无全局超时。search.default_search_timeout
可使用“ 群集更新设置”端点设置和设置设置密钥。设置此值可-1
将全局搜索超时重置为无超时。数组
可使用标准任务取消 机制取消搜索。默认状况下,正在运行的搜索仅检查是否在段边界上取消它,所以取消可能会被大段延迟。经过将动态集群级别设置设置search.low_level_cancellation
为,能够提升搜索取消响应性true
。可是,它带来了更频繁的取消检查的额外开销,这在大型快速运行的搜索查询中是显而易见的。更改此设置仅影响更改后开始的搜索。缓存
默认状况下,Elasticsearch不会根据请求命中的分片数拒绝任何搜索请求。虽然Elasticsearch将优化协调节点上的搜索执行,但大量分片会对CPU和内存产生重大影响。以这样的方式组织数据一般是一个更好的主意,即更少的大分片。若是您要配置软限制,能够更新action.search.shard_count.limit
群集设置以拒绝搜索过多分片的搜索请求。架构
request参数max_concurrent_shard_requests
可用于控制搜索API将为请求执行的最大并发分片请求数。此参数应用于保护单个请求不会使群集过载(例如,默认请求将命中群集中的全部索引,若是每一个节点的分片数量很高,则可能致使碎片请求被拒绝)。此默认值基于群集中的数据节点数,但最多256
。
2.multi-index,multi-type:多索引,多类型搜索
GET /book/_search?q=name:bb
返回name字段包含‘bb’的全部文档(模糊查询)
response:
{ "took": 1, "timed_out": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": 1, "max_score": 4.181759, "hits": [ { "_index": "book", "_type": "english", "_id": "nwmH_mQBbhSmAk-T97Mf", "_score": 4.181759, "_source": { "name": "bb传交换机发个沙发覆盖否", "age": 12, "class": "dsfdsf", "addr": "中国" } } ] } }
GET /twitter/tweet,user/_search?q=user:kimchy
GET book1,book/_search?q=name:bb
GET _all/_search?q=name:bb
或者
GET _search?q=name:bb
其余参数解释以下:
|
查询字符串(映射到 |
|
在查询中未定义字段前缀时使用的默认字段。 |
|
分析查询字符串时要使用的分析器名称。 |
|
是否应分析通配符和前缀查询。默认为 |
|
应在协调节点上一次减小的分片结果数。若是请求中潜在的分片数量很大,则应将此值用做保护机制,以减小每一个搜索请求的内存开销。 |
|
要使用的默认运算符能够是 |
|
若是设置为true将致使忽略基于格式的失败(如向数字字段提供文本)。默认为false。 |
|
对于每一个命中,包含如何计算命中得分的解释。 |
|
设置为 |
|
每一个匹配返回的文档的选择性存储字段,逗号分隔。不指定任何值将致使没有字段返回。 |
|
排序执行。能够是 |
|
排序时,设置为 |
|
设置为 |
|
搜索超时,将搜索请求限制在指定的时间值内执行,并使用在到期时累积的点击数进行保释。默认为无超时。 |
|
在达到查询执行将提早终止时,为每一个分片收集的最大文档数。若是设置,响应将具备一个布尔字段, |
|
从命中的索引开始返回。默认为 |
|
要返回的点击次数。默认为 |
|
要执行的搜索操做的类型。能够是 |
|
|
官方文档参考:Search Api
POST book1/_search { "query" : { "term" : { "name" : "test goog money" } } }
response
{ "took": 4, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 0, "max_score": null, "hits": [] } }
因为默认分词器把“test goog my money”,分红了三个单词,全部没有匹配到。
post book1/_search { "query": { "match":{ "name":"test goog money" } } }
response
{ "took": 17, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 3, "max_score": 11.610666, "hits": [ { "_index": "book1", "_type": "english", "_id": "5oVDQ2UBRzBxBrDgtIl0", "_score": 11.610666, "_source": { "name": "test goog my money", "age": 12, "class": "dsfdsf", "addr": "中国" } }, { "_index": "book1", "_type": "english", "_id": "32", "_score": 1.8562036, "_source": { "name": "test", "age": "1" } }, { "_index": "book1", "_type": "english", "_id": "33", "_score": 1.8562036, "_source": { "name": "test", "age": "1" } } ] } }
{ "query": { "query_string":{ "query":"test goog my money 国" } } }
response
{ "took": 7, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 22, "max_score": 11.610666, "hits": [ { "_index": "book1", "_type": "english", "_id": "5oVDQ2UBRzBxBrDgtIl0", "_score": 11.610666, "_source": { "name": "test goog my money", "age": 12, "class": "dsfdsf", "addr": "中国" } }, { "_index": "book1", "_type": "english", "_id": "lAmG_mQBbhSmAk-T-bN1", "_score": 2.016771, "_source": { "name": "国1里", "age": 12, "class": "dsfdsf", "addr": "中国" } }, { "_index": "book1", "_type": "english", "_id": "32", "_score": 1.8562036, "_source": { "name": "test", "age": "1" } }, { "_index": "book1", "_type": "english", "_id": "33", "_score": 1.8562036, "_source": { "name": "test", "age": "1" } }, { "_index": "book1", "_type": "english", "_id": "jgmG_mQBbhSmAk-TnrMw", "_score": 1.5432179, "_source": { "name": "国国", "age": 12, "class": "dsfdsf", "addr": "中国" } }, { "_index": "book1", "_type": "english", "_id": "kgmG_mQBbhSmAk-T6bOW", "_score": 1.5067708, "_source": { "name": "国1里国", "age": 12, "class": "dsfdsf", "addr": "中国1" } }, { "_index": "book1", "_type": "english", "_id": "kwmG_mQBbhSmAk-T8bN7", "_score": 1.5067708, "_source": { "name": "国1里国", "age": 12, "class": "dsfdsf", "addr": "中国" } }, { "_index": "book1", "_type": "english", "_id": "mgmH_mQBbhSmAk-TbbMX", "_score": 0.18232156, "_source": { "name": "里个覆盖否", "age": 12, "class": "dsfdsf", "addr": "中国" } }, { "_index": "book1", "_type": "english", "_id": "mwmH_mQBbhSmAk-TerNv", "_score": 0.18232156, "_source": { "name": "里个盖否", "age": 12, "class": "dsfdsf", "addr": "中国" } }, { "_index": "book1", "_type": "english", "_id": "ngmH_mQBbhSmAk-T6LPZ", "_score": 0.13353139, "_source": { "name": "cvh交换机发个沙发覆盖否", "age": 12, "class": "dsfdsf", "addr": "中国" } } ] } }
参数说明:
|
|
|
从某个偏移量中检索命中。默认为 |
|
要返回的点击次数。默认为 |
|
要执行的搜索操做的类型。能够是 |
|
设置为 |
|
|
|
在达到查询执行将提早终止时,为每一个分片收集的最大文档数。若是设置,响应将具备一个布尔字段, |
|
应在协调节点上一次减小的分片结果数。若是请求中潜在的分片数量很大,则应将此值用做保护机制,以减小每一个搜索请求的内存开销。 |
出了上述状况,search_type
,request_cache
和allow_partial_search_results
设置必须做为查询字符串参数传递。搜索请求的其他部分应该在正文中传递。正文内容也能够做为名为的REST参数传递source
。
HTTP GET和HTTP POST均可用于使用body执行搜索。因为并不是全部客户端都支持使用正文GET,所以也容许使用POST。
POST _search { "from" : 0, "size" : 2, "query": { "query_string":{ "query":"test goog my money国" } } }
默认:"from" : 0, "size" : 10
{ "sort" : [ { "name" : "desc" }, "_score" ], "query": { "term":{ "name":"国" } } }
若是报错:
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [class] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
开启该字段 fielddata=true :
PUT /book1/_mapping/english/?pretty {"english":{"properties":{"name":{"type":"text","fielddata":true}}}}
在对其
进行排序时,顺序默认为desc_score
,在对其余任何内容进行排序时,默认为asc。
也能够多个字段排序
{ "sort" : [ { "name" : {"order" : "desc"}}, // 此写法与下面的写法等价 { "age" : "desc" }, "_score" ], "query": { "term":{ "name":"国" } } }
4.1.数组字段排序
Elasticsearch支持按数组或多值字段进行排序。该mode
选项控制选择哪一个数组值以对其所属的文档进行排序。该mode
选项能够具备如下值:
|
选择最低值。 |
|
选择最高价值。 |
|
使用全部值的总和做为排序值。仅适用于基于数字的数组字段。 |
|
使用全部值的平均值做为排序值。仅适用于基于数字的数组字段。 |
|
使用全部值的中位数做为排序值。仅适用于基于数字的数组字段。 |
示例:
POST book1/_search { "sort" : [ {"age" : {"order" : "asc", "mode" : "avg"}} ], "query": { "term":{ "name":"test" } } }
response:
{ "took": 2, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 5, "max_score": null, "hits": [ { "_index": "book1", "_type": "english", "_id": "32", "_score": null, "_source": { "name": "test", "age": "1" }, "sort": [ 1 ] }, { "_index": "book1", "_type": "english", "_id": "33", "_score": null, "_source": { "name": "test", "age": "1" }, "sort": [ 1 ] }, { "_index": "book1", "_type": "english", "_id": "5oVDQ2UBRzBxBrDgtIl0", "_score": null, "_source": { "name": "test goog my money", "age": 12, "class": "dsfdsf", "addr": "中国" }, "sort": [ 12 ] }, { "_index": "book1", "_type": "english", "_id": "54UiUmUBRzBxBrDgfIl9", "_score": null, "_source": { "name": "test goog my money", "age": [ 11, 13, 14 ], "class": "dsfdsf", "addr": "中国" }, "sort": [ 13 ] }, { "_index": "book1", "_type": "english", "_id": "6IUkUmUBRzBxBrDgFok2", "_score": null, "_source": { "name": "test goog my money", "age": [ 14, 54, 45, 34 ], "class": "dsfdsf", "addr": "中国" }, "sort": [ 37 ] } ] } }
该字段必须是嵌套字段才行
POST /_search { "query" : { "term" : { "product" : "chocolate" } }, "sort" : [ { "offer.price" : { "mode" : "avg", "order" : "asc", "nested": { "path": "offer", "filter": { "term" : { "offer.color" : "blue" } } } } } ] }
该missing
参数指定如何其缺乏字段文档应被视为:该missing
值能够被设置为_last
,_first
或自定义的值(将被用于缺乏文档做为排序值)。默认是_last
。
默认状况下,若是没有与字段关联的映射,搜索请求将失败。该unmapped_type
选项容许忽略没有映射但不按其排序的字段。此参数的值用于肯定要发出的排序值。如下是如何使用它的示例:
GET /_search { "sort" : [ { "price" : {"unmapped_type" : "long"} } ], "query" : { "term" : { "product" : "chocolate" } } }
_geo_distance
。这是一个例子,假设
pin.location
是一个类型的字段
geo_point
:
GET /_search { "sort" : [ { "_geo_distance" : { "pin.location" : [-70, 40], "order" : "asc", "unit" : "km", "mode" : "min", "distance_type" : "arc" } } ], "query" : { "term" : { "user" : "kimchy" } } }
GET /_search { "_source": { "includes": [ "obj1.*", "obj2.*" ], "excludes": [ "*.description" ] }, "query" : { "term" : { "user" : "kimchy" } } }
返回匹配includes的,去除匹配excludes的字段!
POST book1/_search
{ "script_fields" : { "test1" : { "script" : { "lang": "painless", "source": "doc['age'].value * 2" } }, "test2" : { "script" : { "lang": "painless", "source": "doc['age'].value * params.factor", "params" : { "factor" : 2.0 } } } }, "query": { "term":{ "name":"test" } } }
response:
{ "took": 135, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 5, "max_score": 2.9026666, "hits": [ { "_index": "book1", "_type": "english", "_id": "5oVDQ2UBRzBxBrDgtIl0", "_score": 2.9026666, "fields": { "test1": [ 24 ], "test2": [ 24 ] } }, { "_index": "book1", "_type": "english", "_id": "6IUkUmUBRzBxBrDgFok2", "_score": 2.1818507, "fields": { "test1": [ 28 ], "test2": [ 28 ] } }, { "_index": "book1", "_type": "english", "_id": "32", "_score": 1.5205609, "fields": { "test1": [ 2 ], "test2": [ 2 ] } }, { "_index": "book1", "_type": "english", "_id": "33", "_score": 1.5205609, "fields": { "test1": [ 2 ], "test2": [ 2 ] } }, { "_index": "book1", "_type": "english", "_id": "54UiUmUBRzBxBrDgfIl9", "_score": 1.0615592, "fields": { "test1": [ 22 ], "test2": [ 22 ] } } ] } }
POST book1/_search { "script_fields" : { "test1" : { "script" : "params['_source']['addr']" } }, "query": { "term":{ "name":"test" } } }
请注意_source
此处的关键字以导航相似json的模型。
理解之间的区别是很重要的 doc['my_field'].value
和params['_source']['my_field']
。第一个,使用doc关键字,将致使该字段的术语加载到内存(缓存),这将致使更快的执行,但更多的内存消耗。此外,doc[...]
符号仅容许简单的值字段(您不能从中返回json对象),而且仅对非分析或基于单个术语的字段有意义。可是,doc
若是可能的话,仍然是使用文档中值的推荐方法,由于_source
必须在每次使用时加载和解析。使用_source
很是慢。
POST /book1/_search { "query": { "bool":{ "filter":[ {"term":{"name":"test"}}, { "term":{"addr":"中"}} ] } }, "docvalue_fields" : ["name", "addr"] }
repsonse:
{ "took": 7, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 3, "max_score": 0, "hits": [ { "_index": "book1", "_type": "english", "_id": "6IUkUmUBRzBxBrDgFok2", "_score": 0, "_source": { "name": "test goog my money", "age": [ 14, 54, 45, 34 ], "class": "dsfdsf", "addr": "中国" }, "fields": { "name": [ "goog", "money", "my", "test" ], "addr": [ "中", "国" ] } }, { "_index": "book1", "_type": "english", "_id": "54UiUmUBRzBxBrDgfIl9", "_score": 0, "_source": { "name": "test goog my money", "age": [ 11, 13, 14 ], "class": "dsfdsf", "addr": "中国" }, "fields": { "name": [ "goog", "money", "my", "test" ], "addr": [ "中", "国" ] } }, { "_index": "book1", "_type": "english", "_id": "5oVDQ2UBRzBxBrDgtIl0", "_score": 0, "_source": { "name": "test goog my money", "age": 12, "class": "dsfdsf", "addr": "中国" }, "fields": { "name": [ "goog", "money", "my", "test" ], "addr": [ "中", "国" ] } } ] } }
Doc Value和Ffields的更多了解:ES-正排索Doc Values和Field Data
在已经计算聚合以后,将post_filter
其应用于hits
搜索请求最末端的搜索。
POST /shirts/_search { "query": { "bool": { "filter": { "term": { "brand": "gucci" } //询如今能够找到Gucci的全部衬衫,不管颜色如何 } } }, "aggs": { "colors": { "terms": { "field": "color" } //返回流行的(出如今文档最多频率的颜色)的Gucci的全部衬衫 }, "color_red": { "filter": { "term": { "color": "red" } // 颜色为红色的Gucci的全部衬衫 }, "aggs": { "models": { "terms": { "field": "model" } // 最流行的款式(出如今文档最多频率的颜色)的Gucci的全部衬衫 } } } }, "post_filter": { "term": { "color": "red" } // 搜索中删除红色之外的颜色 } }的记录
POST book1/_search { "query":{ "bool": { "filter": [ { "term": { "name": "里" }}, { "term": { "age": "12" }} ] } }, "highlight" : { "fields" : { "name" : {"type" : "plain"} } } }
response:
{ "took": 77, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 11, "max_score": 0, "hits": [ { "_index": "book1", "_type": "english", "_id": "mgmH_mQBbhSmAk-TbbMX", "_score": 0, "_source": { "name": "里个覆盖否", "age": 12, "class": "dsfdsf", "addr": "中国" }, "highlight": { "name": [ "<em>里</em>个覆盖否" ] } }, { "_index": "book1", "_type": "english", "_id": "mwmH_mQBbhSmAk-TerNv", "_score": 0, "_source": { "name": "里个盖否", "age": 12, "class": "dsfdsf", "addr": "中国" }, "highlight": { "name": [ "<em>里</em>个盖否" ] } }, { "_index": "book1", "_type": "english", "_id": "lAmG_mQBbhSmAk-T-bN1", "_score": 0, "_source": { "name": "国1里", "age": 12, "class": "dsfdsf", "addr": "中国" }, "highlight": { "name": [ "国1<em>里</em>" ] } }, { "_index": "book1", "_type": "english", "_id": "lQmH_mQBbhSmAk-TDrNt", "_score": 0, "_source": { "name": "里", "age": 12, "class": "dsfdsf", "addr": "中国" }, "highlight": { "name": [ "<em>里</em>" ] } }, { "_index": "book1", "_type": "english", "_id": "lwmH_mQBbhSmAk-TObNH", "_score": 0, "_source": { "name": "里fgsaf覆盖否", "age": 12, "class": "dsfdsf", "addr": "中国" }, "highlight": { "name": [ "<em>里</em>fgsaf覆盖否" ] } }, { "_index": "book1", "_type": "english", "_id": "mAmH_mQBbhSmAk-TTbO2", "_score": 0, "_source": { "name": "里jhj发个沙发覆盖否", "age": 12, "class": "dsfdsf", "addr": "中国" }, "highlight": { "name": [ "<em>里</em>jhj发个沙发覆盖否" ] } }, { "_index": "book1", "_type": "english", "_id": "kgmG_mQBbhSmAk-T6bOW", "_score": 0, "_source": { "name": "国1里国", "age": 12, "class": "dsfdsf", "addr": "中国1" }, "highlight": { "name": [ "国1<em>里</em>国" ] } }, { "_index": "book1", "_type": "english", "_id": "kwmG_mQBbhSmAk-T8bN7", "_score": 0, "_source": { "name": "国1里国", "age": 12, "class": "dsfdsf", "addr": "中国" }, "highlight": { "name": [ "国1<em>里</em>国" ] } }, { "_index": "book1", "_type": "english", "_id": "nAmH_mQBbhSmAk-Tg7OW", "_score": 0, "_source": { "name": "里盖否", "age": 12, "class": "dsfdsf", "addr": "中国" }, "highlight": { "name": [ "<em>里</em>盖否" ] } }, { "_index": "book1", "_type": "english", "_id": "nQmH_mQBbhSmAk-TkbP4", "_score": 0, "_source": { "name": "里否", "age": 12, "class": "dsfdsf", "addr": "中国" }, "highlight": { "name": [ "<em>里</em>否" ] } } ] } }
默认<em></em>标签包裹,也能够自定义标签,例如:<span></span>
{ "query":{ "bool": { "filter": [ { "term": { "name": "里" }}, { "term": { "age": "12" }} ] } }, "highlight" : { "pre_tags" : ["<span>"], "post_tags" : ["</span>"], "fields" : { "name" : {"type" : "plain"} } } }
{ "query":{ "match": { "name":"the 里" } }, "highlight" : { "pre_tags" : ["<tag1>"], "post_tags" : ["</tag1>"], "type": "plain", "fragment_size" : 20, "number_of_fragments" : 5, "fields" : { "name":{} } } }
force_source:即便字段单独存储,也会根据源突出显示。默认为false
。分段器
指定如何在高亮片断中分解文本:simple
或span
。仅适用于plain
荧光笔。默认为span
。
simple
span
fragment_offset控制要开始突出显示的边距。仅在使用fvh
荧光笔时有效。fragment_size突出显示的片断的大小(以字符为单位)默认为100。
matched_fields:在多个字段上组合匹配以突出显示单个字段。对于以不一样方式分析相同字符串的多字段,这是最直观的。全部matched_fields
必须term_vector
设置为 with_positions_offsets
,但只加载组合匹配的字段,所以只有该字段从store
设置为受益 yes
。仅适用于fvh
荧光笔。
no_match_size:若是没有要突出显示的匹配片断,则要从字段开头返回的文本量。默认为0(不返回任何内容)。
number_of_fragments:要返回的最大片断数。若是片断数设置为0,则不返回任何片断。而是突出显示并返回整个字段内容。当您须要突出显示标题或地址等短文本时,这可能很方便,但不须要分段。若是number_of_fragments
为0,fragment_size
则忽略。默认为5。
order:设置为时按排名突出显示片断score
。默认状况下,片断将按照它们在字段中出现的顺序输出(顺序:) none
。将此选项设置为score
将首先输出最相关的片断。每一个荧光笔都应用本身的逻辑来计算相关性分数。有关 不一样荧光笔如何找到最佳碎片的更多详细信息,请参阅文档高亮显示器如何在内部工做。
phrase_limit:控制考虑的文档中匹配短语的数量。防止fvh
荧光笔分析太多短语并消耗太多内存。使用时matched_fields
,phrase_limit
会考虑每一个匹配字段的短语。提升限制会增长查询时间并消耗更多内存。仅由fvh
荧光笔支持。默认为256。
require_field_match:默认状况下,仅突出显示包含查询匹配的字段。设置require_field_match
为false
突出显示全部字段。默认为true
。
tags_schema:设置为styled
使用内置标记架构。该styled
架构定义了以下的pre_tags
并定义post_tags
为</em>
。
type:unified
,plain
或fvh
。默认为 unified
。
Elasticsearch支持三种hightlighter:unified
,plain
和fvh
(快速矢量荧光笔)。能够指定type
要为每一个字段使用的突出显示器。
该unified
荧光笔使用Lucene的统一hightlighter。这个hightlighter将文本分红句子,并使用BM25算法对单个句子进行评分,就好像它们是语料库中的文档同样。它还支持准确的短语和多项(模糊,前缀,正则表达式)突出显示。这是默认的hightlighter。
该plain hightlighter
使用标准Lucene的hightlighter。它试图在词汇查询中理解单词重要性和任何单词定位标准方面反映查询匹配逻辑。
该plain hightlighter
最适合在单一field突出简单的查询匹配。为了准确反映查询逻辑,它会建立一个微小的内存中索引,并经过Lucene的查询执行计划程序从新运行原始查询条件,以访问当前文档的低级别匹配信息。对每一个字段和须要突出显示的每一个文档重复此操做。若是要在复杂查询的大量文档中突出显示不少字段,咱们建议使用unified hightlighter
postings
或term_vector
字段。
该fvh
荧光笔使用Lucene的快速hightlighter。此突出显示器可用于映射中term_vector
设置为的 字段with_positions_offsets。
term_vector
以with_positions_offsets
增长索引的大小matched_fields