ElasticSearch新手 - 创建第一个索引

时间:2014-07-18 22:10:59

标签: elasticsearch

让客户认为这将 awesome 用于抓取10MB日志文件的卷。我同意阅读它,但似乎坚持创建我的第一个索引。到目前为止:

♦在Windows 8上安装ElasticSearch 1.2.1Curl 7.3.7(SSL用于SSL,在此处:paehl.com/open_source/?CURL_7.37.0)
♦在ES的响应中成功(状态200,hurray,on localhost,127.0.0.1或我的机器的IP都具有200状态) ♦当我尝试创建索引时,没有爱。一直试图按照Joel Abrahamsson的ElasticSearch 101(joelabrahamsson.com/elasticsearch-101/)和Park" ES Cookbook"中的步骤进行操作。错误范围,但最近和最短的与这些相同:

C:\>curl -XPUT 'http://localhost:9200/blog/user/dilbert' -d '{ "name" : "Dilbert Brown" }'
curl: (1) Protocol 'http not supported or disabled in libcurl
curl: (6) Could not resolve host: name
curl: (7) Failed to connect to  port 80: Connection refused
curl: (6) Could not resolve host: Dilbert Brown
curl: (3) [globbing] unmatched close brace/bracket in column 1

之前的消息更加冗长:

C:\>curl -XPUT "http://localhost:9200/test1/test/1" -d' { "title" : "Godfather", "director" : "Coppola", "year" : 1972 }'
{"error":"MapperParsingException[failed to parse]; nested: ElasticsearchParseException[Failed to derive xcontent from (offset=0, length=1): [39]]; ","status":400}curl: (3) [globbing] unmatched brace in column 1
curl: (6) Could not resolve host: title
curl: (7) Failed to connect to  port 80: Connection refused
curl: (6) Could not resolve host: Godfather,
curl: (6) Could not resolve host: director
curl: (7) Failed to connect to  port 80: Connection refused
curl: (6) Could not resolve host: Coppola,
curl: (6) Could not resolve host: year
curl: (7) Failed to connect to  port 80: Connection refused
curl: (6) Could not resolve host: 1972
curl: (3) [globbing] unmatched close brace/bracket in column 1

感觉就像我忽略了一些基本的东西,但作为ES的新手,卷曲和JSON,我感到困惑 - 至少在我的座位上,支架/支架显得平衡。

建议?

3 个答案:

答案 0 :(得分:4)

这是Windows cmd的问题。 您可以通过更改:

来修复它
curl -XPUT 'http://localhost:9200/blog/user/dilbert' -d '{ "name" : "Dilbert Brown" }'

为:

curl -XPUT "http://localhost:9200/blog/user/dilbert" -d "{ """name""" : """Dilbert Brown""" }"

更新:(对于Windows 64位)

curl -XPUT "http://localhost:9200/blog/user/dilbert" -d "{ \"name\" : \"Dilbert Brown\" }"

答案 1 :(得分:0)

似乎windows不喜欢网址周围的单引号。我不能为你测试它,但在网址周围用双引号试试。

我从以下博文中获得了这些信息: http://bartwullems.blogspot.nl/2013/08/curl-1-protocol-not-supported-or.html

答案 2 :(得分:0)

使用弹性搜索教程中指示的json请求消息创建本地文件,转到此目录并执行curl命令,引用此文件:

curl -XPUT http://localhost:9200/shakespeare --data-binary "@_01_specify_schema.json"

其中_01_specify_schema.json是一个包含文件:

{
 "mappings" : {
  "_default_" : {
   "properties" : {
    "speaker" : {"type": "string", "index" : "not_analyzed" },
    "play_name" : {"type": "string", "index" : "not_analyzed" },
    "line_id" : { "type" : "integer" },
    "speech_number" : { "type" : "integer" }
 }}}}

注意在引用文件的名称

之前添加“@”符号