我正在尝试使用 ElasticSearch。我在查询嵌套对象时遇到问题。
我的映射:
curl -X GET http://localhost:9200/testt/resource/_mapping?pretty
{
"resource": {
"properties": {
"bib": {
"type": "nested",
"properties": {
"IssueDate": {
"type": "date",
"format": "dateOptionalTime"
},
"Title": {
"type": "string"
}
}
},
"name": {
"type": "string"
}
}
}
}
我有一个索引资源:
curl -X GET http://localhost:9200/testt/resource/_search?pretty
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1.0,
"hits": [
{
"_index": "testt",
"_type": "resource",
"_id": "1234",
"_score": 1.0,
"_source": {
"name": "SSS",
"bib": {
"Title": "XSD",
"IssueDate": "2012-12-19"
}
}
}
]
}
}
curl -X GET http://localhost:9200/testt/resource/1234?pretty
{
"_index": "testt",
"_type": "resource",
"_id": "1234",
"_version": 1,
"exists": true,
"_source": {
"name": "SSS",
"bib": {
"Title": "XSD",
"IssueDate": "2012-12-19"
}
}
}
但是我无法使用查询请求找到它:
{
"query": {
"nested": {
"path": "bib",
"query": {
"query_string": {
"query": "XSD"
}
}
}
}
}
搜索:curl -X GET http://localhost:9200/testt/resource/_search?pretty -d '{ "query" : { "nested" : {"path" : "bib", "query" : { "query_string" : {"query" : "XSD"} } } } }'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
我的问题是:如何使用嵌套查询来查找我的对象?我对具有bib
包含 word的嵌套对象的对象感兴趣XSD
。对象1234
显然包含XSD
,但我找不到它。你能告诉我我的查询是否正常吗?它出什么问题了?