elasticsearch不返回数组值

时间:2016-09-09 04:09:19

标签: mongodb elasticsearch

我正在尝试从elasticsearch返回一个mongodb文档。正在返回文档,但数组始终为空,例如

curl -XGET 'http://localhost:9200/smartjn/feed_details/_search?q=_id:577905710baf751293410bed&pretty=true'
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "smartjn",
      "_type" : "feed_details",
      "_id" : "577905710baf751293410bed",
      "_score" : 1.0,
      "_source" : {
        "rejectionId" : "",
        "image" : [ ],
        "subward" : "56a6124244fc868a255fe3fe",
        "longi" : "72.8179",
        "subDepartment" : "Environment",
        "vote" : 0,
        "workFlowType" : "Event",
        "wardname" : "Dhokali",
        "title" : "Test Feed for MassUpload :925",
        "approvalStatus" : "approved",
        "adminFlag" : "1",
        "userID" : "superadmin",
        "uniquerefno" : "ED3488",
        "department" : "Social Causes",
        "upVoteUserIds" : [ ],
        "feedStatusDescription" : "03-07-2016 18:00:41",
        "description" : "Test Feed Description for MassUpload :925",
        "sorter" : "2016-07-03T18:00:40.812000",
        "downVoteUserIds" : [ ],
        "muteFeedUserIds" : [ ],
        "lat" : "18.35367",
        "dateCreated" : "03-07-2016 18:00:41",
        "muteUserIds" : [ ],
        "followFeedUserIds" : [ ],
        "feedStatus" : "New",
        "externalRefNo" : "",
        "anonymousFlag" : "0",
        "downVote" : 0
      }
    } ]
  }
}

mongodb中的相同文档会返回所有正确的字段:

rs0:PRIMARY> db.feed_details.find({_id : ObjectId("577905710baf751293410bed")}).pretty()
{
        "_id" : ObjectId("577905710baf751293410bed"),
        "department" : "Social Causes",
        "subDepartment" : "Environment",
        "workFlowType" : "Event",
        "lat" : "18.35367",
        "longi" : "72.8179",
        "title" : "Test Feed for MassUpload :925",
        "description" : "Test Feed Description for MassUpload :925",
        "image" : [ ],
        "userID" : "superadmin",
        "anonymousFlag" : "0",
        "approvalStatus" : "approved",
        "dateCreated" : "03-07-2016 18:00:41",
        "feedStatus" : "New",
        "vote" : 1,
        "downVote" : 0,
        "rejectionId" : "",
        "feedStatusDescription" : "03-07-2016 18:00:41",
        "followFeedUserIds" : [
                "5734236844fc869a32793b7f"
        ],
        "muteFeedUserIds" : [
                "5734236844fc869a32793b7f"
        ],
        "muteUserIds" : [ ],
        "externalRefNo" : "",
        "subward" : "56a6124244fc868a255fe3fe",
        "upVoteUserIds" : [
                "5734236844fc869a32793b7f"
        ],
        "downVoteUserIds" : [ ],
        "uniquerefno" : "ED3488",
        "adminFlag" : "1",
        "sorter" : ISODate("2016-07-03T18:00:40.812Z"),
        "wardname" : "Dhokali"
}

知道我错过了什么吗?

由于

2 个答案:

答案 0 :(得分:0)

卷曲请求非常不正确,有更好的方法。

试试这个

curl -XGET'http://localhost:9200/smartjn/feed_details/577905710baf751293410bed'

答案 1 :(得分:0)

要解决问题,首先要尝试了解问题所在。在这种情况下,问题可能是您的连接器或您的映射。你应该向我们提供有关这方面的信息,以便能够帮助你。

首先使用以下curl请求检查您的实际数据:

curl -XGET 'http://localhost:9200/smartjn/feed_details/577905710baf7512‌​93410bed' 

之后可以在数据中看到您的数组和内容吗?如果您的阵列不在结果中,那么您的问题可能与您的连接器有关。如果您的阵列在那里,您的问题可能是您的映射。