当前位置: 首页 > 知识库问答 >
问题:

如何在kibana中设置fielddata=true

茅曾琪
2023-03-14

我是Kibana新手,将数据加载到Elastic 5.0.0-alpha3中,并使用Kibana5.0.0-alpha3进行可视化。我可以将一些数字字段显示为直方图,但当我想使用文本字段时,我会得到:

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.

我被警告说数据(出版商的名字)可能已经被分析成子字段,但是我还是想显示。

如何设置< code>fielddata=true?

编辑:Kibana github上最近的问题表明这是5.0.0中的新功能,仍在等待答案!

编辑(遵循@Val的答案,并寻求 Elastic 新手的帮助,并希望其他人会发现它很有用)。收录脚本为:

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]
          })
      }
  });

我如何将@Val的方法包含在其中?

共有3个答案

阴靖
2023-03-14

如果你来自《弹性研究权威指南》这本书,试着改变一下

"terms" : { "field" : "interests" },

"terms" : { "field" : "interests.keyword" },

所以,要运行的代码会变成;

GET /megacorp/employee/_search
{
  "aggs": {
    "all_interests": {
      "terms": { "field": "interests.keyword"}
    }
  }
}
吕淮晨
2023-03-14

由于您使用的是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"
            }
          }
        }
      }
    }
  }
}

然后使用my_field字段进行搜索,使用my_field.keyword字段进行聚合、排序或脚本。

my_field关键字是您在基巴纳/格拉法纳中使用的关键字。

孔俊友
2023-03-14

在ES映射中,您需要在< code>publisher字段中设置< code>fielddata:true:

PUT your_index/_mapping/your_type
{
   "your_type": {
      "properties": {
        "publisher": {
          "type": "text",
          "fielddata": true
        }
      }
   }
}

进行此更改后,您需要重新索引数据,但之后 Kibana 将不再抱怨。

更新

可以在“感知”UI 中或通过 curl 执行上述查询

curl -XPUT http://localhost:9200/index -d '{
  "mappings": {
    "type": {
      "properties": {
        "publisher": {
          "type": "text",
          "fielddata": true
        }
      }
    }
  }
}'

或者,您也可以在创建文档之前在Javascript文件中执行它:

client.indices.create({
  index: 'index',
  body: {
      "mappings": {
        "type": {
          "properties": {
            "publisher": {
              "type": "text",
              "fielddata": true
            }
          }
        }
      }
    }
});
 类似资料:
  • 我刚刚使用上的指南在我的Kubernetes集群上安装了一个EFK堆栈https://medium.com/@timfpark/efk-logging-on-kubernetes-on-azure-4c54402459c4 我在上的指南中指出,当通过代理访问它时,它可以工作 http://localhost:8001/api/v1/namespaces/kube-系统/服务/kibana日志记录/

  • 使用OpenID和KeyCloak的Kibana单点登录。我已经按照opendistro文档配置了该设置。https://opendistro.github.io/for-ellasticsearch-docs/docs/security-configuration/openid-connect/ docker-compose.yml keycloak-compose.yml kibana运行在l

  • 问题内容: 我已经设置了代码示例,但是无法使用serilog登录到带有验证的kibana。在这里,我已附上我的代码,请对其进行更正。 问题答案: 步骤1:安装此NuGet软件包“ Serilog.Sinks.Elasticsearch” 步骤2:在App.config或Web.config中添加它 步骤3:在main()的program.cs或Application_Start()的Global.

  • 我在一个实例中安装了elasticsearch,在另一个实例中安装了kibana。这两个服务都在运行,我可以使用curl将elasticsearch及其实例公共ip连接到端口9200版本:7.9.2都假设:公共ip elasticsearch-x.x.x kibana-y.y.y 问题:无法将kibana实例与其curl和公共ip连接到端口5601错误:无法连接到y.y.y.y端口5601:连接被

  • 问题内容: 我正在尝试使用JavaFX中的WebView入门,但是当尝试打开W​​ebView时,我收到以下所示的错误,我该如何解决此问题? 问题答案: 尝试运行WebView时遇到任何错误时,请确保您的VM选项包含模块javafx.web。 虚拟机选项: 在IntelliJ中,您可以通过转到IDE右上方的“编辑配置”按钮来访问VM选项。

  • 问题内容: 我已经使用数据库中的SQL数据库开发了一个窗口服务,该数据库中的记录已满,因此查询执行需要很多时间,而默认命令超时是30S,但我想将其增加到120S。 但是我的应用程序中有很多方法,因此我想从APP.config文件中进行设置,这样它将适用于应用程序级别,任何人都可以告诉我如何实现此目标 谢谢 问题答案: 实现此目的的最简单方法是在类似以下内容的地方添加新条目: 然后,创建一个将填充值