1
client.indices.delete({index: _index});
client.indices.create({
index: _index,
body: {
"settings": {
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 10
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
}
},
"mappings": {
"employee": {
"properties": {
"title": {
"type": "string",
"fields": {
"raw": {"type": "string", "index": "not_analyzed"}
}
},
"description": {
"type": "string",
"fields": {
"autocomplete": {"type": "string", "index_analyzer": "autocomplete"}
}
},
"interests": {
"type": "string"
},
"createdBy": {
"type": "string", "index": "not_analyzed"
},
}
}
}
}
}, function (error, response) {
var body = [];
Feed.find({},function(err, result){
if(err) throw err;
else{
var jdata = JSON.stringify(result);
var jsondata = JSON.parse(jdata);
// console.log("result>>>"+result);
jsondata.forEach(function(item){
body.push({"index": {"_index": _index, "_type": _type}});
body.push(item);
})
}
client.bulk({
body: body
}, function (err, resp) {
console.log('Indexing Completed!');
})
})
})
client.count({_index: 'company',_type: 'employee'},function(err,resp,status) {
console.log("constituencies",resp);
});
Привет @Alsatian, в первый раз я загружаю любые вопросы о stackoverflow, вы можете понять проблему с помощью моего кода. –
@Alsatian это мой правильный формат code.please загляните в него, его работа отлично, и я также получаю консоль «Индексирование завершено!» но когда я проверяю его с помощью команды «curl -XGET» http: // localhost: 9200/_cat/indices? v '', он показывает имя индекса, но проблема в docs.count показывает 0. –
Ваш код не был распознан как кода по форматированию. Я отредактировал его, чтобы быть более читаемым. Я не буду вникать в это, я не эксперт Elastica, я просто пришел сюда, потому что все первые сообщения просматриваются старшими пользователями. – Alsatian