我试图将ElasticSearch用作数据存储,以便按名字查找某些人。 我尝试创建索引,添加了单词,更改了映射,但是当我试图通过JaroWinkler& amp; Levenstein算法,它什么都没有回来。
第1步 PUT:http://127.0.0.1:9200/list
req.onload=function() {
const dataset = json.data;
const w = 880;
const h = 440;
const yScale = d3.scaleLinear();
yScale.domain([0,d3.max(dataset, (d) => d[1])]);
yScale.range([10,h]) // axis will start at 10
const svg = d3.select('body')
.append("svg")
.attr("width", w)
.attr("height", h);
svg.selectAll("rect")
.select("body")
.data(dataset)
.enter()
.append("rect")
.attr("x", (d, i) => {
return i * 3.2;
})
.attr("y", (d) => {
return (h - yScale(d[1]));
})
.attr("width", 3.2 * .95)
.attr("height", (d, i) => {
return (yScale(d[1]));
})
.attr("class", "bar")
.append("title")
.text((d) => {
return d[0];
})
console.log('one') // logs
const xAxis = d3.axisBottom(xScale); // PROBLEM
console.log('two') // won't log
svg.append("g")
.attr("transform", "translate(0," + (h) + ")")
.call(xAxis);
console.log('three') // won't log
const yAxis = d3.axisLeft(yScale);
svg.append("g")
.attr("transform", "translate(100,50)")
.call(yAxis);
console.log('four'); // won't log
};
console.log('this will log')
});
回答
{
"mappings": {
"main": {
"properties": {
"ppl_name": {
"type": "text"
}
}
}
}
}
第2步
发布/发送http://127.0.0.1:9200/list/main/1
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "list"
}
回答
{"ppl_name":"oleksandroleksandrovychborysenko"}
{"ppl_name":"oleksandr oleksandrovych borysenko"}
第3步 获取http://127.0.0.1:9200/list/_mapping 回答:
{
"_index": "list",
"_type": "main",
"_id": "2",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"created": true
}
第4步
发表 {
"list": {
"mappings": {
"main": {
"properties": {
"ppl_name": {
"type": "text"
}
}
}
}
}
}
身体
http://127.0.0.1:9200/list/main/_search
和ANSWER
{
"suggest": {
"text" : "oleksandr oleksandrovych borysenko",
"levenstein" : {
"term" : {
"string_distance": "levenstein",
"field" : "ppl_name"
}
},
"jarowinkler" : {
"term" : {
"string_distance": "jarowinkler",
"field" : "ppl_name"
}
}
}
}
任何人都可以帮我解决这个问题吗?