diff --git a/src/test/resources/rest-api-spec/test/analysis-hanlp/10_basic.yml b/src/test/resources/rest-api-spec/test/analysis-hanlp/10_basic.yml new file mode 100644 index 0000000..ff816f3 --- /dev/null +++ b/src/test/resources/rest-api-spec/test/analysis-hanlp/10_basic.yml @@ -0,0 +1,21 @@ +"Tokenizer": + - do: + indices.analyze: + body: + text: 我购买了道具和服装。 + tokenizer: hanlp + - length: { tokens: 3 } + - match: { tokens.0.token: 购买 } + - match: { tokens.1.token: 道具 } + - match: { tokens.2.token: 服装 } +--- +"Analyzer": + - do: + indices.analyze: + body: + text: 我购买了道具和服装。 + analyzer: hanlp-index + - length: { tokens: 3 } + - match: { tokens.0.token: 购买 } + - match: { tokens.1.token: 道具 } + - match: { tokens.2.token: 服装 } diff --git a/src/test/resources/rest-api-spec/test/analysis-hanlp/20_search.yml b/src/test/resources/rest-api-spec/test/analysis-hanlp/20_search.yml new file mode 100644 index 0000000..f4df498 --- /dev/null +++ b/src/test/resources/rest-api-spec/test/analysis-hanlp/20_search.yml @@ -0,0 +1,30 @@ +--- +"Index Hanlp content": + - do: + indices.create: + index: test + body: + mappings: + type: + properties: + text: + type: text + analyzer: hanlp + + - do: + index: + index: test + type: type + id: 1 + body: { "text": "我购买了道具和服装" } + - do: + indices.refresh: {} + + - do: + search: + index: test + body: + query: + match: + text: 购买 + - match: { hits.total: 1 }