无法从Elasticsearch获取数据

时间:2014-12-02 06:34:06

标签: java elasticsearch replication spring-data couchbase

我正在使用弹簧数据处理 Couchbase Elasticsearch 。我有一个从Couchbase到Elasticsearch的复制。现在,我可以使用spring数据在couchbase中保存数据,正确保存数据并将其复制到Elasticsearch中。尝试从Elasticsearch读取时,它显示为null,结果中只显示id值。当我直接在Elasticsearch中保存时,可以正确读取。我想这是因为数据的结构变化。我该如何解决这个问题?

复制后Elasticsearch中的数据:

{

"_index": "streams",
"_type": "couchbaseDocument",
"_id": "e8c7999c-67c8-47a4-b235-726d89102f83",
"_score": 1,
"_source": {
    "meta": {
        "id": "e8c7999c-67c8-47a4-b235-726d89102f83",
        "rev": "3-000007c43e1293830000000000000000",
        "expiration": 0,
        "flags": 0
    },
    "doc": {
        "createdOn": "20141201183646786",
        "activityId": "c3c0dc11-16b5-479b-80c5-93d2ce34d77d",
        "_class": "com.netspective.streams.model.Activity",
        "documentType": "Activity",
        "objectId": "UserAgent_1",
        "subjectId": "{"actionId":"111"}",
        "actionId": "2",
        "updatedOn": "20141201183646786",
        "deleteStatus": false
    }
}

}

直接插入的Elasticsearch中的数据:

{

"_index": "streams",
"_type": "couchbaseDocument",
"_id": "45ebb326-a33e-43f2-9fd7-60953cb14772",
"_score": 1,
"_source": {
    "id": "45ebb326-a33e-43f2-9fd7-60953cb14772",
    "activityId": "56d291bc-eacd-4942-b26d-08025eec0ab1",
    "subjectId": "{"actionId":"123"}",
    "objectId": "UserAgent_1",
    "documentType": "Activity",
    "createdOn": "20141202113523979",
    "updatedOn": "20141202113523979",
    "deleteStstus": false,
    "action": "2"
}

}

1 个答案:

答案 0 :(得分:0)

如果您更改了数据结构,则可能需要更新Elasticsearch映射。

请查看Indexing IssuesElasticsearch plugin documentation部分,其中介绍了如何解决此问题。