我们新建索引film2
然后映射的时候,指定smartcn分词;
{
"properties": {
"title": {
"type": "text",
"analyzer": "smartcn"
},
"publishDate": {
"type": "date"
},
"content": {
"type": "text",
"analyzer": "smartcn"
},
"director": {
"type": "keyword"
},
"price": {
"type": "float"
}
}
}
然后执行前面的数据代码;
这样前面film索引,数据是标准分词,中文全部一个汉字一个汉字分词;film2用了smartcn,根据内置中文词汇分词;
我们用java代码来搞分词搜索;
先定义一个静态常量:
private static final String ANALYZER="smartcn";/**
*