ElasticSearch学习笔记
1、设置highlight 结果返回数据长度:fragment_size,默认是100
{ "query" : {...}, "highlight" : { "order" : "score", "fields" : { "content" : {"fragment_size" : 150, "number_of_fragments" : 3} } } }
当把 number_of_fragments 设置为0时,默认返回匹配到的全部content字段的内容(已做highlight处理的)。
手册:http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#_highlighted_fragments
2、多关键字同时匹配、包含的检索语句
{ "query_string" : { "default_field" : "content", "query" : "this AND that OR thus" } }
可以用在bool > must/should 下
手册:http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html