我是Kibana的新手,将数据加载到Elastic 5.0.0-alpha3并使用Kibana 5.0.0-alpha3进行Visualize.我可以将一些数字字段显示为直方图,但是当我想使用文本字段时,我得到:
Visualize: Fielddata is disabled on text fields by default. Set fielddata=true on [publisher] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.
Run Code Online (Sandbox Code Playgroud)
我被警告说,数据(发布者的名字)可能已被分析到子字段,但无论如何我想显示.
我该怎么设置fielddata=true?
编辑:最近关于Kibana github的问题表明这是5.0.0中的新功能,仍在等待答案!
编辑(关注@ Val的答案,并要求弹性新手帮助,并希望其他人会发现它有用).摄取脚本是:
fs = require('fs')
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
host: 'localhost:9200',
log: 'trace'
});
fs.readFile('/Users/pm286/workspace/cmdev/getpapers/20160602/crossref_results.json', (err, data) => {
if (err) throw err;
document = JSON.parse(data)
document = JSON.parse(data)
for(i=0;i<document.length;i++) {
client.create({
index: 'index',
type: 'type',
body: document[i]
})
}
});
Run Code Online (Sandbox Code Playgroud)
我如何在此包含@ Val的方法?
Val*_*Val 45
在ES映射中,您需要fielddata:true在您的publisher字段中进行设置:
PUT your_index/_mapping/your_type
{
"your_type": {
"properties": {
"publisher": {
"type": "text",
"fielddata": true
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在进行此更改后,您需要重新编制数据索引,但之后Kibana将不再抱怨.
UPDATE
您可以在Sense UI中执行上述查询,也可以通过curl 执行上述查询
curl -XPUT http://localhost:9200/index -d '{
"mappings": {
"type": {
"properties": {
"publisher": {
"type": "text",
"fielddata": true
}
}
}
}
}'
Run Code Online (Sandbox Code Playgroud)
或者您也可以在创建文档之前在Javascript文件中执行它:
client.indices.create({
index: 'index',
body: {
"mappings": {
"type": {
"properties": {
"publisher": {
"type": "text",
"fielddata": true
}
}
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
小智 22
由于您使用的是Elastic 5.x(我现在写的是5.2),您应该使用新的关键字支持而不是在索引字段上启用fielddata.
https://www.elastic.co/guide/en/elasticsearch/reference/5.2/fielddata.html提供了有关优缺点以及如何设置此信息的良好信息.从页面:
PUT my_index
{
"mappings": {
"my_type": {
"properties": {
"my_field": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后使用"my_field"字段进行搜索,使用"my_field.keyword"字段进行聚合,排序或脚本.
my_field.keyword是你在Kibana/Grafana中使用的.
Ahm*_*med 18
如果您来自“ElasticsearchThe Definitive Guide”一书,请尝试更改此
"terms" : { "field" : "interests" },
Run Code Online (Sandbox Code Playgroud)
到
"terms" : { "field" : "interests.keyword" },
Run Code Online (Sandbox Code Playgroud)
因此,要运行的代码将变为;
GET /megacorp/employee/_search
{
"aggs": {
"all_interests": {
"terms": { "field": "interests.keyword"}
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 7
此代码修复了此问题.
PUT megacorp/_mapping/employee
{
"employee": {
"properties": {
"interests": {
"type": "text",
"fielddata": true
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以此代码将在此后运行:
GET /megacorp/employee/_search
{
"aggs": {
"all_interests": {
"terms": { "field": "interests"}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
64277 次 |
| 最近记录: |