多くのjsonドキュメントがCloudantデータベースに格納されています。文書の構造:Cloudantは、すべての最後の値を数えるためにビューを作成します。配列フィールド
{
"_id": "00229e31d5751d337abf409a4bd75492",
"_rev": "1-d95d7ad32264d233453a0436b1557e7d",
"timestamp": "2017-07-04T21:28:46.886Z",
"APIresponse": {
"intents": [
{
"intent": "greetings",
"confidence": 1
},
{
"intent": "machineBusy",
"confidence": 0
},
{
"intent": "set_weights",
"confidence": 0
},
{
"intent": "faqGuidelinesPAAmount",
"confidence": 0
},
{
"intent": "chat",
"confidence": 0
},
{
"intent": "feedback-no",
"confidence": 0
},
{
"intent": "faqGuidelinesWhatsnew",
"confidence": 0
},
{
"intent": "faqGuidelinesChildren",
"confidence": 0
},
{
"intent": "thanks",
"confidence": 0
},
{
"intent": "faqGuidelinesPAvsFederal",
"confidence": 0
}
],
"entities": [],
"input": {
"text": "hey"
},
"output": {
"text": [
"Hey there!",
"How a beautiful day to train :) Do you agree #firstName?"
],
"nodes_visited": [
"Greetings",
"Initial greetings",
"node_2_1495711348295"
],
"error": "SpelEvaluationException when evaluating DialogNode Id [check PROFILING interrupted ASPFINDER]. Condition [$trainingContext.status == \"no_tp\" && $aspFinder.dob != null || $aspFinder.height != null || $aspFinder.weight != null || $aspFinder.impedIsPresent != null || $aspFinder.goal != null || $aspFinder.timesAWeek != null || $aspFinder.duration != null || $aspFinder.location != null || $aspFinder.level != null || $userContext.height != null] evaluated to FALSE.\norg.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'weight' cannot be found on null\n",
"log_messages": [
{
"level": "err",
"msg": "SpelEvaluationException when evaluating DialogNode Id [check PROFILING interrupted ASPFINDER]. Condition [$trainingContext.status == \"no_tp\" && $aspFinder.dob != null || $aspFinder.height != null || $aspFinder.weight != null || $aspFinder.impedIsPresent != null || $aspFinder.goal != null || $aspFinder.timesAWeek != null || $aspFinder.duration != null || $aspFinder.location != null || $aspFinder.level != null || $userContext.height != null] evaluated to FALSE.\norg.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'weight' cannot be found on null\n"
}
]
},
"context": {
"system": {
"dialog_stack": [
{
"dialog_node": "node_2_1495711348295"
}
],
"dialog_request_counter": 5,
"dialog_turn_counter": 5,
"_node_output_map": {
"node_3_1495711396477": [
0
],
"node_1_1495037449418": [
0,
0,
1
],
"node_12_1494424156763": [
0,
3,
0,
1,
2,
4
],
"in exercise": [
0
],
"Workout Feedback": [
0,
2,
1,
0,
3
],
"Greetings": [
0
],
"node_2_1495711348295": [
0,
2,
1,
0
]
}
},
"repeat": false,
"lastMsg": [
"Great job!",
"We're done for today training! Great job :)"
],
"conversation_id": "919d2d6b-e085-4fbe-bd12-19486aa0394e",
"last": {
"trainingContext": {
"status": "no_workout",
"suggested_workout_id": "W-fb2038d7d45a48a6af844a53f52a1759-T-74e57d317b9649feb5f024c049766fd7-F-technogym"
},
"notify_ui": "workout_closed",
"output": {
"nodes_visited": [
"node_9_1494423774989",
"node_1_1494427286758",
"node_12_1494424156763"
],
"text": [
"Great job!",
"We're done for today training! Great job :)"
],
"log_messages": []
}
},
"_currentSession": {
"current_exe": 7
},
"currentSession": {
"feedback": 5
},
"_timestamp": "2017-07-04T21:28:46.561Z",
"trainingContext": {
"status": "no_workout",
"suggested_workout_id": "W-fb2038d7d45a48a6af844a53f52a1759-T-74e57d317b9649feb5f024c049766fd7-F-technogym"
},
"userContext": {
"height": 160,
"userID": "e37e39f4-61ba-41da-a356-2c6cbfae8392",
"lastName": "#lastName",
"facilityId": "4419597c-b63e-4358-b8ba-cc388bb192c3",
"weight": 56,
"userToken": "MjAxNzA3MDQyMTI4MzR8MzQyYzJkZmEyNGVkNGZlZDhiOWU5NDg0NWE1YzAxNTJ8ZWMxZDM4ZDdkMzU5NDhkMGE2MGNkOGMwYjhmYjlkZjl8MXxXLiBFdXJvcGUgU3RhbmRhcmQgVGltZXxpdC1JVHxlMzdlMzlmNDYxYmE0MWRhYTM1NjJjNmNiZmFlODM5Mnx8fHwxfDF8MHwxMDB8fHw1OHw2ODk0fDB8Y29tLm15d2VsbG5lc3M1.BC8BBB1E2066444DEA5F5E1F42627CF6443F3077",
"firstName": "#firstName",
"dob": "03/07/1986"
}
}
}
}
値ODFは、私が興味JSONは常に配列フィールドAPIresponse.outout.nodes_visitedで最後です。具体的には、配列フィールドAPIresponse.outout.nodes_visitedの最後の値のカウントと、そのカウント(カウントの名前)に関連付けられた関連値を取得する構造を持っています。
私は通常、Cloudantをクエリするためにセレクタを使用しますが、それは私が探している特定のカウントを取得する方法を提供していないようです。
デザインドキュメントでmap reduce関数を作成しようとしましたが、成功できませんでした。
その後の質問は以下のとおりです。
- 私はCloudantで配列フィールドの最後の要素にアクセスするにはどうすればよいですか?
- データベースの配列の最後の要素の合計数はどのようにして取得できますか?
あなたがマップ減らすビューでこれを行うことができます
フィリッポ
は答えをありがとうございました。私はあなたの指示に従いますが、私がカール仲間を調整するとき、私はこのエラーを受け取ります: {"エラー": "service_unavaible": "理由": "サービスunavailable"} –
データのサブセットをテストできるようにすることはできますか? 100人のドキュメントのカップル、言いなさい。 – xpqz
もちろん:https://www.dropbox.com/s/p7gav3vw6vsemx5/test_view_filippo_leoncini.json?dl=0 –