0
我是新來Elasticserach和傑克遜JSON。有一個簡單的查詢(搜索按國家索引),我嘗試使用JsonGenerator,傑克遜jsonGenerator產生Elasticsearch查詢DSL
"{\n" +
" \"query\" : {\n" +
" \"match\": { \"exporting_country\":\"" + countryCode + "\"} \n" +
"} \n"+
"}"
JsonGenerator代碼,
JsonGenerator jGenerator = jfactory.createGenerator(outputStream);
jGenerator.writeStartObject();
jGenerator.writeFieldName("query");
jGenerator.writeStartObject();
jGenerator.writeFieldName("match");
jGenerator.writeStringField("exporting_country", countryCode);
jGenerator.writeEndObject();
jGenerator.writeEndObject();
jGenerator.close();
它拋出了一個錯誤:
Can not write a field name, expecting a value