2013-04-15 76 views
2

我將ES 0.20.6與elasticsearch-river-jdbc plugin一起使用。 我創建了一個工程,並使用一條河:爲JDBC彈性搜索河設置映射

SQL="SELECT ..." 
curl -XPUT 'localhost:9200/_river/myindex_river/_meta' -d '{ 
    "type" : "jdbc", 
    "jdbc" : { 
     "driver" : "org.postgresql.Driver", 
     "url" : "jdbc:postgresql://localhost:5432/mydb_db", 
     "user" : "myuser", 
     "password" : "mypassword", 
     "sql" : "'"$SQL"'" 
    }, 
    "index" : { 
     "index" : "myindex", 
     "type" : "mytype", 
     "type_mapping" : null 
    } 
}' 

現在我想的是添加類型映射爲the option is defined in the plugin documentation。但我真的cant't找出語法和始終得到以下錯誤(與"Source: "部分的變化取決於我嘗試)

org.elasticsearch.index.mapper.MapperParsingException: Failed to parse mapping definition 
     at org.elasticsearch.index.mapper.DocumentMapperParser.extractMapping(DocumentMapperParser.java:237) 
     at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:147) 
     at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:379) 
     at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:375) 
     at org.elasticsearch.cluster.metadata.MetaDataMappingService$4.execute(MetaDataMappingService.java:309) 
     at org.elasticsearch.cluster.service.InternalClusterService$2.run(InternalClusterService.java:223) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
     at java.lang.Thread.run(Thread.java:662) 
Caused by: org.elasticsearch.common.jackson.core.JsonParseException: Unexpected character ('=' (code 61)): was expecting a colon to separate field name and value 
at [Source: {mytype={properties={active={index_analyzer=standard, store=yes, type=boolean}}}}; line: 1, column: 9] 
     at org.elasticsearch.common.jackson.core.JsonParser._constructError(JsonParser.java:1378) 
     at org.elasticsearch.common.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:599) 
     at org.elasticsearch.common.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:520) 
     at org.elasticsearch.common.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:616) 
     at org.elasticsearch.common.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:48) 
     at org.elasticsearch.common.xcontent.support.XContentMapConverter.readMap(XContentMapConverter.java:70) 
     at org.elasticsearch.common.xcontent.support.XContentMapConverter.readOrderedMap(XContentMapConverter.java:60) 
     at org.elasticsearch.common.xcontent.support.AbstractXContentParser.mapOrdered(AbstractXContentParser.java:116) 
     at org.elasticsearch.index.mapper.DocumentMapperParser.extractMapping(DocumentMapperParser.java:235) 
     ... 8 more 

回答

4

我想您所提交的東西,甚至不是一個正確的JSON對象。我可以想象,type_mapping對象必須包含映射,幾乎與使用put mapping apicreating索引所提交的映射幾乎相同。

+1

哇,謝謝。我甚至都沒有想過。我使用繼續的json符號來設置映射,但是我需要在我的json對象中有一個json字符串...工作方式:''type_mapping「:」{\「mytype \」:{\「properties \」:{\ 「活性\」:{\ 「類型\」:\ 「布爾\」,\ 「存儲\」:\ 「是\」}}}}「'。非常感謝 ! – Crystark

+0

我必須補充一點,我使用的是Chrome Sense,並且甚至在json對象內的回車符也非常特殊。 – dickyj

+0

在ElasticSearch 1.0.0中,你應該這樣做:http://ondrej-kvasnovsky.blogspot.com/2013/10/how-to-configure-jdbc-river-for.html –