8

Applicationモデル用とDatabasesモデル用 (多対多リレーショナル) の2 つのインデックスがあります。

各ドキュメントは、他のモデルからの属性を含むように非正規化されています

Application
          |_ vendor_name
          |_ databases
                 |_ db_1
                 |_ db_2


Database
       |_ database_applications
                 |_ app_1
                        |_vendor_name
                 |_ app_2
                        |_ vendor_name

ベンダー名のマルチインデックス検索を実行しています - 両方のインデックスから適切な結果が得られているようです。

チャレンジは vendor_name フィールドで適切に集計されています

次の集計を使用すると、結果がデータベースからのみの場合に機能するようです。私も試しfield: '*vendor_name'ましたが、うまくいかないようです。

私は何が欠けていますか?モデルを変更する必要がありますか?

   aggregation:
       vendor_name: {
            terms: {
                field: "database_applications.vendor_name"
            }
        }

更新 1:

@Andrie-Stefan によると、両方のインデックス マッピングのより正確な表現を以下に示します (短縮のために省略)。

データベース

{
  "company-company_databases": {
    "aliases": {},
    "mappings": {
      "company_database": {
        "properties": {
          "company_applications": {
            "properties": {
              "application_id": {
                "type": "long"
              },
              "application_name": {
                "type": "string"
              },
              "business_owner": {
                "type": "string"
              },
              "company_system_applications": {
                "properties": {
                  "allow_add_request": {
                    "type": "string"
                  },
                  "allow_remove_request": {
                    "type": "string"
                  },
                  "asset_type": {
                    "type": "string"
                  },
                  "company_application_id": {
                    "type": "long"
                  },
                  "company_application_name": {
                    "type": "string"
                  },
                  "company_business_owner": {
                    "type": "string"
                  },
                  "company_division_id": {
                    "type": "long"
                  },
                  "company_it_app_steward": {
                    "type": "string"
                  },
                  "company_notes": {
                    "type": "string"
                  },
                  "company_system_id": {
                    "type": "long"
                  },
                  "company_vendor": {
                    "type": "string"
                  },
                  "id": {
                    "type": "long"
                  },
                  "it_app_steward": {
                    "type": "string"
                  },
                  "it_owner": {
                    "type": "string"
                  },
                  "last_modified": {
                    "type": "string"
                  },
                  "last_modified_by": {
                    "type": "string"
                  },
                  "media_location": {
                    "type": "string"
                  },
                  "media_source": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "owned_by": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "status_id": {
                    "type": "long"
                  },
                  "system_application": {
                    "properties": {
                      "division": {
                        "type": "string"
                      },
                      "id": {
                        "type": "long"
                      },
                      "name": {
                        "type": "string"
                      },
                      "owner_id": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "steward_id": {
                        "type": "string"
                      },
                      "vendor_name": {
                        "type": "string"
                      },
                      "vendor_url_web_site": {
                        "type": "string"
                      },
                      "version": {
                        "type": "string"
                      }
                    }
                  },
                  "vendor_name": {
                    "type": "string",
                    "fields": {
                      "raw": {
                        "type": "string",
                        "index": "not_analyzed"
                      }
                    }
                  },
                  "version": {
                    "type": "string"
                  }
                }
              },
              "division_id": {
                "type": "long"
              },
              "it_app_steward": {
                "type": "string"
              },
              "notes": {
                "type": "string"
              },
              "software_inventory_id": {
                "type": "long"
              },
              "vendor": {
                "type": "string"
              }
            }
          },
          "company_instances": {
            "properties": {
              "business_environment_id": {
                "type": "long"
              },
              "cgi_service_id": {
                "type": "long"
              },
              "char_set": {
                "type": "string"
              },
              "confirmed_license_purchase_dt": {
                "type": "string"
              },
              "company_server": {
                "properties": {
                  "business_environment_id": {
                    "type": "long"
                  },
                  "division_id": {
                    "type": "long"
                  },
                  "domain": {
                    "type": "string"
                  },
                  "hw_platform_id": {
                    "type": "long"
                  },
                  "ip_address": {
                    "type": "string"
                  },
                  "location_id": {
                    "type": "long"
                  },
                  "no_of_cpu": {
                    "type": "long"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "os_platform_id": {
                    "type": "long"
                  },
                  "os_version": {
                    "type": "string"
                  },
                  "server_id": {
                    "type": "long"
                  },
                  "server_name": {
                    "type": "string"
                  }
                }
              },
              "description": {
                "type": "string"
              },
              "division_id": {
                "type": "long"
              },
              "edition_id": {
                "type": "long"
              },
              "instance_id": {
                "type": "long"
              },
              "instance_name": {
                "type": "string"
              },
              "itap_have_access": {
                "type": "string"
              },
              "listener_port": {
                "type": "long"
              },
              "notes": {
                "type": "string"
              },
              "patch_number": {
                "type": "string"
              },
              "rdbms_type_id": {
                "type": "long"
              },
              "server_id": {
                "type": "long"
              },
              "service_level_id": {
                "type": "long"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "db_security_model_id": {
            "type": "long"
          },
          "schema_or_db": {
            "type": "string"
          },
          "schema_or_db_id": {
            "type": "long"
          },
          "schema_or_db_type_id": {
            "type": "long"
          }
        }
      }
    },
    "settings": {
      "index": {
        "creation_date": "1442976578465",
        "uuid": "TxQZoNSpR5qa2Y2ERZzuYw",
        "number_of_replicas": "1",
        "number_of_shards": "5",
        "version": {
          "created": "1070299"
        }
      }
    },
    "warmers": {}
  }
}

応用

{
  "applications": {
    "aliases": {},
    "mappings": {
      "application": {
        "properties": {
          "application_view": {
            "properties": {
              "app_name": {
                "type": "string"
              },
              "app_status": {
                "type": "string"
              },
              "app_steward_name": {
                "type": "string"
              },
              "app_suite": {
                "type": "string"
              },
              "app_vendor_name": {
                "type": "string"
              },
              "app_version": {
                "type": "string"
              },
              "assignment_group": {
                "type": "string"
              },
              "business_domain_name": {
                "type": "string"
              },
              "exception": {
                "type": "string"
              },
              "id": {
                "type": "long"
              },
              "it_owner_name": {
                "type": "string"
              },
              "service_level": {
                "type": "string"
              }
            }
          },
          "assignment_group": {
            "type": "string"
          },
          "company_databases": {
            "properties": {
              "backup_history_info": {
                "type": "string"
              },
              "company_applications": {
                "properties": {
                  "alternate_name": {
                    "type": "string"
                  },
                  "application_id": {
                    "type": "long"
                  },
                  "application_name": {
                    "type": "string"
                  },
                  "business_owner": {
                    "type": "string"
                  },
                  "company_system_applications": {
                    "properties": {
                      "aka": {
                        "type": "string"
                      },
                      "allow_add_request": {
                        "type": "string"
                      },
                      "allow_remove_request": {
                        "type": "string"
                      },
                      "asset_type": {
                        "type": "string"
                      },
                      "contract_number": {
                        "type": "string"
                      },
                      "cost_level": {
                        "type": "string"
                      },
                      "company_alternate_name": {
                        "type": "string"
                      },
                      "company_application_id": {
                        "type": "long"
                      },
                      "company_application_name": {
                        "type": "string"
                      },
                      "company_business_owner": {
                        "type": "string"
                      },
                      "company_division_id": {
                        "type": "long"
                      },
                      "company_it_app_steward": {
                        "type": "string"
                      },
                      "company_notes": {
                        "type": "string"
                      },
                      "company_system_id": {
                        "type": "long"
                      },
                      "company_vendor": {
                        "type": "string"
                      },
                      "description": {
                        "type": "string"
                      },
                      "display_in_catalog": {
                        "type": "string"
                      },
                      "id": {
                        "type": "long"
                      },
                      "inform_of_removal": {
                        "type": "string"
                      },
                      "is_restricted": {
                        "type": "string"
                      },
                      "it_app_steward": {
                        "type": "string"
                      },
                      "it_owner": {
                        "type": "string"
                      },
                      "last_modified": {
                        "type": "string"
                      },
                      "last_modified_by": {
                        "type": "string"
                      },
                      "media_location": {
                        "type": "string"
                      },
                      "media_source": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "os_environment": {
                        "type": "string"
                      },
                      "owned_by": {
                        "type": "string"
                      },
                      "retirement_date": {
                        "type": "date",
                        "format": "dateOptionalTime"
                      },
                      "status": {
                        "type": "string"
                      },
                      "status_id": {
                        "type": "long"
                      },
                      "suite_name": {
                        "type": "string"
                      },
                      "system_application": {
                        "properties": {
                          "assignment_group": {
                            "type": "string"
                          },
                          "division": {
                            "type": "string"
                          },
                          "id": {
                            "type": "long"
                          },
                          "name": {
                            "type": "string"
                          },
                          "owner_id": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "steward_id": {
                            "type": "string"
                          },
                          "suite": {
                            "type": "string"
                          },
                          "vendor_name": {
                            "type": "string"
                          },
                          "vendor_url_web_site": {
                            "type": "string"
                          },
                          "version": {
                            "type": "string"
                          }
                        }
                      },
                      "vendor_name": {
                        "type": "string"
                      },
                      "version": {
                        "type": "string"
                      }
                    }
                  },
                  "division_id": {
                    "type": "long"
                  },
                  "it_app_steward": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "software_inventory_id": {
                    "type": "long"
                  },
                  "vendor": {
                    "type": "string"
                  }
                }
              },
              "company_instances": {
                "properties": {
                  "business_environment_id": {
                    "type": "long"
                  },
                  "cgi_service_id": {
                    "type": "long"
                  },
                  "char_set": {
                    "type": "string"
                  },
                  "confirmed_license_purchase_dt": {
                    "type": "string"
                  },
                  "company_server": {
                    "properties": {
                      "business_environment_id": {
                        "type": "long"
                      },
                      "division_id": {
                        "type": "long"
                      },
                      "domain": {
                        "type": "string"
                      },
                      "hw_platform_id": {
                        "type": "long"
                      },
                      "ip_address": {
                        "type": "string"
                      },
                      "location_id": {
                        "type": "long"
                      },
                      "no_of_cpu": {
                        "type": "long"
                      },
                      "notes": {
                        "type": "string"
                      },
                      "os_platform_id": {
                        "type": "long"
                      },
                      "os_version": {
                        "type": "string"
                      },
                      "server_id": {
                        "type": "long"
                      },
                      "server_name": {
                        "type": "string"
                      }
                    }
                  },
                  "description": {
                    "type": "string"
                  },
                  "division_id": {
                    "type": "long"
                  },
                  "edition_id": {
                    "type": "long"
                  },
                  "instance_id": {
                    "type": "long"
                  },
                  "instance_name": {
                    "type": "string"
                  },
                  "itap_have_access": {
                    "type": "string"
                  },
                  "listener_port": {
                    "type": "long"
                  },
                  "location_id": {
                    "type": "long"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "patch_number": {
                    "type": "string"
                  },
                  "rdbms_type_id": {
                    "type": "long"
                  },
                  "server_id": {
                    "type": "long"
                  },
                  "service_level_id": {
                    "type": "long"
                  },
                  "version": {
                    "type": "string"
                  }
                }
              },
              "db_security_model_id": {
                "type": "long"
              },
              "notes": {
                "type": "string"
              },
              "schema_or_db": {
                "type": "string"
              },
              "schema_or_db_id": {
                "type": "long"
              },
              "schema_or_db_type_id": {
                "type": "long"
              }
            }
          },
          "division": {
            "type": "string",
            "fields": {
              "raw": {
                "type": "string",
                "index": "not_analyzed"
              }
            }
          },
          "id": {
            "type": "long"
          },
          "name": {
            "type": "string"
          },
          "owner": {
            "properties": {
              "email_address": {
                "type": "string"
              },
              "id": {
                "type": "long"
              },
              "name": {
                "type": "string",
                "fields": {
                  "raw": {
                    "type": "string",
                    "index": "not_analyzed"
                  }
                }
              },
              "search_type": {
                "type": "string"
              },
              "user_id": {
                "type": "string"
              }
            }
          },
          "owner_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "fields": {
              "raw": {
                "type": "string",
                "index": "not_analyzed"
              }
            }
          },
          "steward": {
            "properties": {
              "email_address": {
                "type": "string"
              },
              "id": {
                "type": "long"
              },
              "name": {
                "type": "string",
                "fields": {
                  "raw": {
                    "type": "string",
                    "index": "not_analyzed"
                  }
                }
              },
              "search_type": {
                "type": "string"
              },
              "user_id": {
                "type": "string"
              }
            }
          },
          "steward_id": {
            "type": "string"
          },
          "suite": {
            "type": "string"
          },
          "vendor_name": {
            "type": "string",
            "fields": {
              "raw": {
                "type": "string",
                "index": "not_analyzed"
              }
            }
          },
          "vendor_url_web_site": {
            "type": "string"
          },
          "version": {
            "type": "string"
          }
        }
      }
    },
    "settings": {
      "index": {
        "creation_date": "1442970067540",
        "uuid": "O7DTaCSESbqhjJpv62T0Wg",
        "number_of_replicas": "1",
        "number_of_shards": "5",
        "version": {
          "created": "1070299"
        }
      }
    },
    "warmers": {}
  }
}

4

1 に答える 1