将JSON文件导入/索引到Elasticsearch [英] Import/Index a JSON file into Elasticsearch

查看:607
本文介绍了将JSON文件导入/索引到Elasticsearch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Elasticsearch的新手,已经手动输入数据,直到此为止。例如,我已经做了这样的事情:

I am new to Elasticsearch and have been entering data manually up until this point. For example I've done something like this:

$ curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{
    "user" : "kimchy",
    "post_date" : "2009-11-15T14:12:12",
    "message" : "trying out Elastic Search"
}'

我现在有一个.json文件,我想索引这进入弹性搜索。我试过这样的事情没有成功:

I now have a .json file and I want to index this into Elasticsearch. I've tried something like this to no success:

curl -XPOST 'http://jfblouvmlxecs01:9200/test/test/1' -d lane.json

如何导入.json文件?有没有必要首先确定映射是否正确的步骤?

How do I import a .json file? Are there steps I need to take first to ensure the mapping is correct?

推荐答案

如果要使用文件,正确的命令卷曲是这样的:

The right command if you want to use a file with curl is this:

curl -XPOST 'http://jfblouvmlxecs01:9200/test/test/1' -d @lane.json

elasticsearch是无模式的,因此您不一定需要映射。如果您发送json,并使用默认映射,每个字段将被索引并使用标准分析器

elasticsearch is schemaless, therefore you don't necessarily need a mapping. If you send the json as it is and you use the default mapping every field will be indexed and analyzed using the standard analyzer.

如果要通过命令行与弹性搜索进行交互,您可能需要查看弹性框架应该比卷曲稍微更轻一些。

If you want to interact with elasticsearch through the command line you may want to have a look at the elasticshell which should be a little bit handier than curl.

这篇关于将JSON文件导入/索引到Elasticsearch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆