elasticsearch Mongoostic如何设置术语建议器
我正在使用ElasticSearch的完成建议器在数据库中查找标记。它可以工作,但我想改为术语建议器。因为有些标签有两个单词,比如“abc def”,如果我搜索“abc”,我可以找到它,但我不能用“def”。因为完成提示器仅适用于前缀搜索 如何使用术语建议器?我在Mongoostic博士身上什么也没找到 这是我使用完成建议器的代码:elasticsearch Mongoostic如何设置术语建议器,elasticsearch,mongoose,autocomplete,term,mongoosastic,elasticsearch,Mongoose,Autocomplete,Term,Mongoosastic,我正在使用ElasticSearch的完成建议器在数据库中查找标记。它可以工作,但我想改为术语建议器。因为有些标签有两个单词,比如“abc def”,如果我搜索“abc”,我可以找到它,但我不能用“def”。因为完成提示器仅适用于前缀搜索 如何使用术语建议器?我在Mongoostic博士身上什么也没找到 这是我使用完成建议器的代码: // create tag model var mongoose = require('mongoose'); var mongoosastic = req
// create tag model
var mongoose = require('mongoose');
var mongoosastic = require('mongoosastic');
var tagSchema = mongoose.Schema({
name: {
type: String,
es_indexed: true,
es_analyzer: 'simple',
es_payloads: true,
es_type: 'completion',
}
});
tagSchema.plugin(mongoosastic);
var Tag = mongoose.model('Tag', tagSchema);
// add some data
Tag.createMapping(function(err, mapping) {
async.each(tags, function(t, done) {
var newTag = new Tag(t);
newTag.save(function(err) {
if (err) { console.log(err); }
newTag.on('es-indexed', function(err, res) {
if (err) { console.log(err); }
done();
});
});
});
});
// looking for some tags with keyword
Tag.search(
null,
{
suggest: {
"tags-suggest": {
"text": keyword,
"term": {
"field": "name",
"size": 10
}
}
},
size: 0
},
function(err, data) {
console.log(data);
}
)
谢谢