一般使用highlight_options函數設置高亮:函數
s = s.highlight_options(order='score')
使用highlight_options函數也是能夠爲單獨的字段設置高亮:code
s = s.highlight('title') # or, including parameters: s = s.highlight('title', fragment_size=50)
fragement用來指定高亮字段的最大字符長度。it
輸出高亮字段:io
response = s.execute() for hit in response: for fragment in hit.meta.highlight.title: print(fragment)