From 0b5c5db13bca1ed6f3423d582409aa1937d70b70 Mon Sep 17 00:00:00 2001 From: Ranger Tsao Date: Wed, 10 Jan 2018 21:24:06 +0800 Subject: [PATCH] add Examples --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/README.md b/README.md index 8703d72..2351180 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,57 @@ gradle mvn # Notice Package `com.hankcs.lucene` copy from [hanlp-lucene-plugin](https://github.com/hankcs/hanlp-lucene-plugin) + +# Index and Highlight + +## Mapping + + +`PUT test/_mapping/test` +```json +{ + "properties": { + "content": { + "type": "text", + "analyzer": "hanlp-index", + "search_analyzer": "hanlp-index", + "index_options": "offsets" + } + } +} +``` + +## Index Document + +PUT /test/test/1 +```json +{ + "content": ["中华人民共和国","地大物博"] +} +``` + +## Highlight + +POST /test/test/_search +```json +{ + "query": { + "match": { + "content": "中华" + } + }, + "highlight": { + "pre_tags": [ + "" + ], + "post_tags": [ + "" + ], + "fields": { + "content": {} + } + } +} +``` + +