執行搜索時,它將廣播到全部索引/索引分片(副本之間的循環)。能夠經過提供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