这是一个执行您想要执行的操作的示例。至少从我对你问题的理解来看。索引和查询:
curl -XPUT localhost:9200/test/
curl -XPOST localhost:9200/test/testtype/1 -d '{"array" : [{ "title" : "The Great Gatsby" }, { "title" : "Enders game" }] }'
curl -XPOST localhost:9200/test/testtype/2 -d '{"array" : [{ "title" : "Enders game" }, { "title" : "The name of the wind" }] }'
curl -XPOST localhost:9200/test/testtype/3 -d '{"array" : [{ "title" : "The name of the wind" }, { "title" : "The Great Gatsby" }]}'
curl -XPOST localhost:9200/test/testtype/_search -d '{
"query" : {
"term" : { "title" : "great" }
}}'
结果:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 0.5,
"hits" : [ {
"_index" : "test",
"_type" : "testtype",
"_id" : "1",
"_score" : 0.5, "_source" : {"array" : [{ "title" : "The Great Gatsby" }, { "title" : "Enders game" }] }
}, {
"_index" : "test",
"_type" : "testtype",
"_id" : "3",
"_score" : 0.5, "_source" : {"array" : [{ "title" : "The name of the wind" }, { "title" : "The Great Gatsby" }]}
} ]
}
}