问:
unique records in elastic search
how to find all the unique records in elastic search based on an attribute in it..
Is there a way?

```<code>GET  questiondetails/question/_search
{
    "size": 0,
    "aggs" : {
        "Name" : {
            "terms" : {
                "field" : "owner.user_id.keyword"
            }
        }
    }
}
</code>```

I tried this way.. But I want it to give all the docs wherever user id is present in the whole record.
Whether it is in inner loop also....

Is there a way to get this in a single query instead of making in multiple queries..
Here is my sample record.

```<code>{
    "_index": "questiondetails",
    "_type": "question",
    "_id": "BOktPnABW1evGoA0CqDZ",
    "_score": 1,
    "_source": {
      "tags": [
        "android",
        "kotlin"
      ],
      "owner": {

        "user_id": "10633771"
      },

      "reply_count": "1",

      "reply": [
        {
          "owner": {

            "user_id": "12632101",
            "user_type": "registered",

          }

        }
      ]
    }
  }
</code>```

Index

```{
  "questiondetails": {
    "aliases": {},
    "mappings": {
      "question": {
        "properties": {
          "accepted_answer_id": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "answer_count": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "answers": {
            "properties": {
              "answer_id": {
                "type": "long"
              },
              "body": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "body_markdown": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "comment_count": {
                "type": "long"
              },
              "comments": {
                "properties": {
                  "comment_id": {
                    "type": "long"
                  },
                  "creation_date": {
                    "type": "long"
                  },
                  "edited": {
                    "type": "boolean"
                  },
                  "owner": {
                    "properties": {
                      "accept_rate": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "display_name": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "link": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "profile_image": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "reputation": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "user_id": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "user_type": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      }
                    }
                  },
                  "post_id": {
                    "type": "long"
                  },
                  "reply_to_user": {
                    "properties": {
                      "display_name": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "link": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "profile_image": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "reputation": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "user_id": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "user_type": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      }
                    }
                  },
                  "score": {
                    "type": "long"
                  }
                }
              },
              "creation_date": {
                "type": "long"
              },
              "down_vote_count": {
                "type": "long"
              },
              "is_accepted": {
                "type": "boolean"
              },
              "last_activity_date": {
                "type": "long"
              },
              "last_edit_date": {
                "type": "long"
              },
              "link": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "owner": {
                "properties": {
                  "accept_rate": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "display_name": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "link": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "profile_image": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "reputation": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "user_id": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "user_type": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  }
                }
              },
              "question_id": {
                "type": "long"
              },
              "score": {
                "type": "long"
              },
              "share_link": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "title": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "up_vote_count": {
                "type": "long"
              }
            }
          },
          "body": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "body_markdown": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "close_vote_count": {
            "type": "long"
          },
          "comment_count": {
            "type": "long"
          },
          "comments": {
            "properties": {
              "body": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "body_markdown": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "comment_id": {
                "type": "long"
              },
              "creation_date": {
                "type": "long"
              },
              "edited": {
                "type": "boolean"
              },
              "owner": {
                "properties": {
                  "accept_rate": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "display_name": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "link": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "profile_image": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "reputation": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "user_id": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "user_type": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  }
                }
              },
              "post_id": {
                "type": "long"
              },
              "reply_to_user": {
                "properties": {
                  "accept_rate": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "display_name": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "link": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "profile_image": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "reputation": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "user_id": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "user_type": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  }
                }
              },
              "score": {
                "type": "long"
              }
            }
          },
          "creation_date": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "delete_vote_count": {
            "type": "long"
          },
          "down_vote_count": {
            "type": "long"
          },
          "is_answered": {
            "type": "boolean"
          },
          "last_activity_date": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "last_edit_date": {
            "type": "long"
          },
          "last_editor": {
            "properties": {
              "accept_rate": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "display_name": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "link": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "profile_image": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "reputation": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "user_id": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "user_type": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "link": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "owner": {
            "properties": {
              "accept_rate": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "display_name": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "link": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "profile_image": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "reputation": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "user_id": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "user_type": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "question_id": {
            "type": "long"
          },
          "reopen_vote_count": {
            "type": "long"
          },
          "score": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "share_link": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "tags": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "title": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "up_vote_count": {
            "type": "long"
          },
          "view_count": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    },
    "settings": {
      "index": {
        "creation_date": "1581585452123",
        "number_of_shards": "5",
        "number_of_replicas": "1",
        "uuid": "_nvo_G7ZRvqMIwLmddUXPw",
        "version": {
          "created": "6020399"
        },
        "provided_name": "questiondetails"
      }
    }
  }
}
```

答:
You can achieve what you want with a scripted terms aggregation, like this:

```<code>POST questions/_search
{
  "size": 0,
  "aggs": {
    "ids": {
      "terms": {
        "script": "[doc['owner.user_id.keyword'].value, doc['reply.owner.user_id.keyword'].value]",
        "size": 10
      }
    }
  }
}
</code>```

Title: unique records in elastic search

Body:
how to find all the unique records in elastic search based on an attribute in it..
Is there a way?

GET  questiondetails/question/_search
{
    "size": 0,
    "aggs" : {
        "Name" : {
            "terms" : {
                "field" : "owner.user_id.keyword"
            }
        }
    }
}

I tried this way.. But I want it to give all the docs wherever user id is present in the whole record.
Whether it is in inner loop also....

Is there a way to get this in a single query instead of making in multiple queries..
Here is my sample record.

{
    "_index": "questiondetails",
    "_type": "question",
    "_id": "BOktPnABW1evGoA0CqDZ",
    "_score": 1,
    "_source": {
      "tags": [
        "android",
        "kotlin"
      ],
      "owner": {

        "user_id": "10633771"
      },

      "reply_count": "1",

      "reply": [
        {
          "owner": {

            "user_id": "12632101",
            "user_type": "registered",

          }

        }
      ]
    }
  }

Index

{
  "questiondetails": {
    "aliases": {},
    "mappings": {
      "question": {
        "properties": {
          "accepted_answer_id": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "answer_count": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "answers": {
            "properties": {
              "answer_id": {
                "type": "long"
              },
              "body": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "body_markdown": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "comment_count": {
                "type": "long"
              },
              "comments": {
                "properties": {
                  "comment_id": {
                    "type": "long"
                  },
                  "creation_date": {
                    "type": "long"
                  },
                  "edited": {
                    "type": "boolean"
                  },
                  "owner": {
                    "properties": {
                      "accept_rate": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "display_name": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "link": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "profile_image": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "reputation": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "user_id": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "user_type": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      }
                    }
                  },
                  "post_id": {
                    "type": "long"
                  },
                  "reply_to_user": {
                    "properties": {
                      "display_name": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "link": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "profile_image": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "reputation": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "user_id": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                      "user_type": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      }
                    }
                  },
                  "score": {
                    "type": "long"
                  }
                }
              },
              "creation_date": {
                "type": "long"
              },
              "down_vote_count": {
                "type": "long"
              },
              "is_accepted": {
                "type": "boolean"
              },
              "last_activity_date": {
                "type": "long"
              },
              "last_edit_date": {
                "type": "long"
              },
              "link": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "owner": {
                "properties": {
                  "accept_rate": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "display_name": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "link": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "profile_image": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "reputation": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "user_id": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "user_type": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  }
                }
              },
              "question_id": {
                "type": "long"
              },
              "score": {
                "type": "long"
              },
              "share_link": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "title": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "up_vote_count": {
                "type": "long"
              }
            }
          },
          "body": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "body_markdown": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "close_vote_count": {
            "type": "long"
          },
          "comment_count": {
            "type": "long"
          },
          "comments": {
            "properties": {
              "body": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "body_markdown": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "comment_id": {
                "type": "long"
              },
              "creation_date": {
                "type": "long"
              },
              "edited": {
                "type": "boolean"
              },
              "owner": {
                "properties": {
                  "accept_rate": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "display_name": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "link": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "profile_image": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "reputation": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "user_id": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "user_type": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  }
                }
              },
              "post_id": {
                "type": "long"
              },
              "reply_to_user": {
                "properties": {
                  "accept_rate": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "display_name": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "link": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "profile_image": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "reputation": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "user_id": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "user_type": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  }
                }
              },
              "score": {
                "type": "long"
              }
            }
          },
          "creation_date": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "delete_vote_count": {
            "type": "long"
          },
          "down_vote_count": {
            "type": "long"
          },
          "is_answered": {
            "type": "boolean"
          },
          "last_activity_date": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "last_edit_date": {
            "type": "long"
          },
          "last_editor": {
            "properties": {
              "accept_rate": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "display_name": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "link": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "profile_image": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "reputation": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "user_id": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "user_type": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "link": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "owner": {
            "properties": {
              "accept_rate": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "display_name": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "link": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "profile_image": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "reputation": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "user_id": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "user_type": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "question_id": {
            "type": "long"
          },
          "reopen_vote_count": {
            "type": "long"
          },
          "score": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "share_link": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "tags": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "title": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "up_vote_count": {
            "type": "long"
          },
          "view_count": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    },
    "settings": {
      "index": {
        "creation_date": "1581585452123",
        "number_of_shards": "5",
        "number_of_replicas": "1",
        "uuid": "_nvo_G7ZRvqMIwLmddUXPw",
        "version": {
          "created": "6020399"
        },
        "provided_name": "questiondetails"
      }
    }
  }
}

Body:
You can achieve what you want with a scripted terms aggregation, like this:

POST questions/_search
{
  "size": 0,
  "aggs": {
    "ids": {
      "terms": {
        "script": "[doc['owner.user_id.keyword'].value, doc['reply.owner.user_id.keyword'].value]",
        "size": 10
      }
    }
  }
}


来源: stackexchange

问:
Kafka Topic And Offset
I have a question,Suppose there is a TOPIC T1 and there are two Consumer C1 and C2 belongs to two different groups and current offset is 0.We know that Kafka maintains the Offset for consumer.So if C1 consume the message and Offset becomes 1 then what will happen if C2 consume the message will it start from 1 offset or it will start consume the message from 0 offset?. Means how offset will be maintains for two different consumer Group?.

Thanks

答: As You have mentioned there are two consumer with different group. So In that case C2 will consume from the begining. It means offset will start from 0 in C2 consumer. Offset might be different only If you will use same group in both consumer. </p>

ContentLicense: CC BY-SA 4.0

Title: Kafka Topic And Offset


问:
How to pass default value loaded into form input to the payload
I'm making an edit form which inside Modal. Form inputs has defaultValue that comes from props with an name, age and strength as default value. If I change all inputs value, everything works fine, but if I change only one input value when I console.log payload I got and empty strings, but only value that I changed goes to the payload.  How can I make that even I change only one input payload gets inputs default value from props?

My code is here:

```<code>import React, { Component } from 'react';
import './Form.scss';
import axios from 'axios';

class Form extends Component {
    constructor(props){
        super(props);
        this.state = {
            id: this.props.gnomeId,
            submitedName: '',
            submitedAge: '',
            submitedStrength: ''
        }
        this.onSubmit = this.onSubmit.bind(this);
    }

    handleChange = (event) => {
        this.setState({
            [event.target.name]: event.target.value,
        });
    }

    onSubmit(event) {
        event.preventDefault();

        const gnome = {
                name: this.state.submitedName,
                age: this.state.submitedAge,
                strenght: this.state.submitedStrength,
              }
        console.log(gnome);

        axios.post(`${API}/${this.state.id}`, {gnome})
        .then( res => {
            console.log(res);
            console.log(res.data);
        });
    }

    render() {
        return(
            <form onSubmit={this.onSubmit}>
                <div>
                    <label htmlFor="name">Name</label>
                    <input type="text" name="submitedName" id="name" defaultValue={this.props.gnomeName} onChange={this.handleChange}/>
                </div>
                <div>
                    <label htmlFor="age">Age</label>
                    <input type="text" name="submitedAge" id="age" defaultValue={this.props.gnomeAge} onChange={this.handleChange}/>
                </div>
                <div>
                    <label htmlFor="strength">Strength</label>
                    <input type="text" name="submitedStrength" id="strength" defaultValue={this.props.gnomeStrength} onChange={this.handleChange}/>
                </div>
                <button type="submit" className="submit-btn">Submit</button>
            </form>
        )
    }
}

export default Form;
</code>```

答:
Just set the initial state to the default values:</p>

```<code>super(props);
this.state = {
    id: this.props.gnomeId,
    submitedName: props.gnomeName,
    submitedAge: props.gnomeAge,
    submitedStrength: props.gnomeStrength
}
</code>```

Body:
I'm making an edit form which inside Modal. Form inputs has defaultValue that comes from props with an name, age and strength as default value. If I change all inputs value, everything works fine, but if I change only one input value when I console.log payload I got and empty strings, but only value that I changed goes to the payload.  How can I make that even I change only one input payload gets inputs default value from props?

My code is here:

import React, { Component } from 'react';
import './Form.scss';
import axios from 'axios';

class Form extends Component {
    constructor(props){
        super(props);
        this.state = {
            id: this.props.gnomeId,
            submitedName: '',
            submitedAge: '',
            submitedStrength: ''
        }
        this.onSubmit = this.onSubmit.bind(this);
    }

    handleChange = (event) => {
        this.setState({
            [event.target.name]: event.target.value,
        });
    }

    onSubmit(event) {
        event.preventDefault();

        const gnome = {
                name: this.state.submitedName,
                age: this.state.submitedAge,
                strenght: this.state.submitedStrength,
              }
        console.log(gnome);

        axios.post(`${API}/${this.state.id}`, {gnome})
        .then( res => {
            console.log(res);
            console.log(res.data);
        });
    }

    render() {
        return(
            <form onSubmit={this.onSubmit}>

                    Name
                    <input type="text" name="submitedName" id="name" defaultValue={this.props.gnomeName} onChange={this.handleChange}/>

                    Age
                    <input type="text" name="submitedAge" id="age" defaultValue={this.props.gnomeAge} onChange={this.handleChange}/>

                    Strength
                    <input type="text" name="submitedStrength" id="strength" defaultValue={this.props.gnomeStrength} onChange={this.handleChange}/>

                <button type="submit" className="submit-btn">Submit</button>
            </form>
        )
    }
}

export default Form;

Body:
Just set the initial state to the default values:

super(props);
this.state = {
    id: this.props.gnomeId,
    submitedName: props.gnomeName,
    submitedAge: props.gnomeAge,
    submitedStrength: props.gnomeStrength
}


问:
why colour not showing as argument in ggplot for R language
I was practicing course and stumbled upon argument "colour" in aes function so I assigned an object to differentiate data but R console is not showing colour as auto-suggestion argument.

Can you help me by explaining why?

** I am new to R**

答:
The reason for that colour, fill and so forth does not show up as part of the aes arguments, is that aes(...) as a function does not necessarily take these arguments. The reaction of aes(...) depends on the specific geom_[...] (and stat_[...]), but most often contains at least colour and color and some size or width argument.

For specifics you should always check the documentation for the specific geom_[...] using for example help(geom_point) where the relevant aestethics are listed under Aesthetics. For the specific example we get:

Aesthetics

geom_point() understands the following aesthetics (required aesthetics are in bold):

x

y

alpha

colour

fill

group

shape

size

stroke

Learn more about setting these aesthetics in vignette("ggplot2-specs").


问:
Bug or am I doing something wrong? Usercontrol Painting
```<code>private void UserControl1_Paint(object sender, PaintEventArgs e)
{
    e.Graphics.DrawEllipse(Pens.Black, new Rectangle(-200, -500, this.Width + 400, this.Height + 420));
}
</code>```

Paste the above code into a usercontrol. Drop the usercontrol onto a form and anchor it to all 4 points.

In the designer (Under Visual Studio 2010) it renders perfectly (even as you resize). Run it and try and resize the form and the ellipse becomes skewed.

Here are two examples both after resizes the first while running, the second in the designer.

Obviously the behavior in the designer can't always be assumed to be the same (Although it would be nice) but my understanding is that the code above is completely legal. Am I wrong?

答:
You can manually Invalidate control while resizing</p>

```<code>private void Form1_Resize(object sender, EventArgs e)
{
    userControl11.Invalidate();
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
private void UserControl1_Paint(object sender, PaintEventArgs e)
{
    e.Graphics.DrawEllipse(Pens.Black, new Rectangle(-200, -500, this.Width + 400, this.Height + 420));
}

Paste the above code into a usercontrol. Drop the usercontrol onto a form and anchor it to all 4 points.

In the designer (Under Visual Studio 2010) it renders perfectly (even as you resize). Run it and try and resize the form and the ellipse becomes skewed.

Here are two examples both after resizes the first while running, the second in the designer.

Obviously the behavior in the designer can't always be assumed to be the same (Although it would be nice) but my understanding is that the code above is completely legal. Am I wrong?

Body:
You can manually Invalidate control while resizing

private void Form1_Resize(object sender, EventArgs e)
{
    userControl11.Invalidate();
}


问:
DocuSign Integration Siebel IP14
Is it feasible to integrate DocuSign with On Premise CRM applications (Siebel Remote) or it only supports integration with Cloud Solutions?</p>

答:
Yes, you should be able to integrate the two products. The first issue is to decide what you want to accomplish.

Sending out documents to be signed via DocuSign is one REST API call (after you've handled OAuth authentication of the sender).

For new eSignature applications, DocuSign highly recommends using the eSignature REST v2.1 API. The DocuSign SOAP API is supported, but is in a holding pattern.

Title: DocuSign Integration Siebel IP14


问:
bootstrap row going above another in mobile view in html
i have created an html section in bootstrap, which contains a container and two main rows, the code is like below:

<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

This is Heading

Price

              + Add

Standard photography at best value to turn make lifetime memories from your party. Photographer will be available for maximum 3 hours. 150 - 200 soft copies will be delivered through CD within 10 working days.

This is Heading

Price

              + Add

Standard photography at best value to turn make lifetime memories from your party. Photographer will be available for maximum 3 hours. 150 - 200 soft copies will be delivered through CD within 10 working days.

        + Show more add-ons

```
</div>
</div>
</p>

<p>now the problem is </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="row">
  <div class="col-md-10" id="showmore">
    + Show more add-ons
  </div>
</div></code>```

this row is going above the first row in mobile view, i have tried using mobile query to adjust but still its not moving down, can anyone please tell me what could be wrong here, thanks in advance

答:
Remove height (181px) from ".addonscard" class in CSS and try :</p>

```<code>.addonscard {
  width: 100%;
  height: auto; // height is updated from 181px to auto..
  padding: 2%;
  border: 1px solid #efefef;}
</code>```

Body:
i have created an html section in bootstrap, which contains a container and two main rows, the code is like below:

<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

This is Heading

Price

              + Add

Standard photography at best value to turn make lifetime memories from your party. Photographer will be available for maximum 3 hours. 150 - 200 soft copies will be delivered through CD within 10 working days.

This is Heading

Price

              + Add

Standard photography at best value to turn make lifetime memories from your party. Photographer will be available for maximum 3 hours. 150 - 200 soft copies will be delivered through CD within 10 working days.

        + Show more add-ons

now the problem is

    + Show more add-ons

this row is going above the first row in mobile view, i have tried using mobile query to adjust but still its not moving down, can anyone please tell me what could be wrong here, thanks in advance

Body:
Remove height (181px) from ".addonscard" class in CSS and try :

.addonscard {
  width: 100%;
  height: auto; // height is updated from 181px to auto..
  padding: 2%;
  border: 1px solid #efefef;}


问:
How to convert an iOS project to a Framework
I want to convert my iOS project into a framework. I already going throw some solutions but can figure it out because those are not descriptive as much. Can anyone help me? Here are the solutions that I already tried:
(1) Convert Existing iOS App to framework
(2) how can i create a framework from existing project?
(3) Convert Existing iOS App to framework</p>

答:
File -> New -> Target -> FrameWork -> Make sure its in your app bundle.
Then in your project you need to make a class where your rootviewController will open.
Then you have to add your project storyboard to that target. and your controllers.


答:
set height for rows and set float right for them!

@media only screen and (max-width: 576px) {
  .row{
  height:fit-content;
  float:right;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

<style>
  .addonscard {
    width: 100%;
    height: 181px;
    padding: 2%;
    border: 1px solid #efefef;
  }

  .addonsimage {
    width: 100%;
  }

  .add-on-add-unit {
    color: #30ac15;
    border: 1px solid #30ac15;
  }

  .add-on-add-unit {
    font-size: 14px;
    line-height: 20px;
    padding: 2px 12px 2px 10px;
    border-radius: 10px;
    display: inline-block;
  }

  .add-on-add-unit {
    color: #30ac15;
    border: 1px solid #30ac15;
  }

  .addonsdesc {
    font-size: 13px
  }

  #showmore {
    text-align: center;
  }

  .clearme {
    clear: both;
    margin-top: 2%;
  }
</style>

<section class="addons">

  <div class="container">

    <div class="row">

      <div class="col-md-5">
        <div class="addonscard">
          <div class="row">
            <div class="col-md-4">
              <img class="addonsimage" src="test1.jpg" />
            </div>
            <div class="col-md-8">
              <h4>This is Heading</h4>
              <p>Price</p>
              + Add
            </div>
          </div>
          <div class="row">
            <div class="col-md-12">
              <p class="addonsdesc">Standard photography at best value to turn make lifetime memories from your party. Photographer will be available for maximum 3 hours. 150 - 200 soft copies will be delivered through CD within 10 working days. </p>
            </div>
          </div>
        </div>
      </div>

      <div class="col-md-5">
        <div class="addonscard">
          <div class="row">
            <div class="col-md-4">
              <img class="addonsimage" src="test2.jpg" />
            </div>
            <div class="col-md-8">
              <h4>This is Heading</h4>
              <p>Price</p>
              + Add
            </div>
          </div>

          <div class="row">
            <div class="col-md-12">
              <p class="addonsdesc">Standard photography at best value to turn make lifetime memories from your party. Photographer will be available for maximum 3 hours. 150 - 200 soft copies will be delivered through CD within 10 working days. </p>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="clearme"></div>
    <div class="row">
      <div class="col-md-10" id="showmore">
        + Show more add-ons
      </div>
    </div>

  </div></code>```

Title: bootstrap row going above another in mobile view in html

Body:
set height for rows and set float right for them!

@media only screen and (max-width: 576px) {
  .row{
  height:fit-content;
  float:right;
  }
}

<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

<style>
  .addonscard {
    width: 100%;
    height: 181px;
    padding: 2%;
    border: 1px solid #efefef;
  }

  .addonsimage {
    width: 100%;
  }

  .add-on-add-unit {
    color: #30ac15;
    border: 1px solid #30ac15;
  }

  .add-on-add-unit {
    font-size: 14px;
    line-height: 20px;
    padding: 2px 12px 2px 10px;
    border-radius: 10px;
    display: inline-block;
  }

  .add-on-add-unit {
    color: #30ac15;
    border: 1px solid #30ac15;
  }

  .addonsdesc {
    font-size: 13px
  }

  #showmore {
    text-align: center;
  }

  .clearme {
    clear: both;
    margin-top: 2%;
  }
</style>

<section class="addons">

  <div class="container">

    <div class="row">

      <div class="col-md-5">
        <div class="addonscard">
          <div class="row">
            <div class="col-md-4">
              <img class="addonsimage" src="test1.jpg" />
            </div>
            <div class="col-md-8">
              <h4>This is Heading</h4>
              <p>Price</p>
              <a href="" class="add-on-add-unit">+ Add</a>
            </div>
          </div>
          <div class="row">
            <div class="col-md-12">
              <p class="addonsdesc">Standard photography at best value to turn make lifetime memories from your party. Photographer will be available for maximum 3 hours. 150 - 200 soft copies will be delivered through CD within 10 working days. </p>
            </div>
          </div>
        </div>
      </div>

      <div class="col-md-5">
        <div class="addonscard">
          <div class="row">
            <div class="col-md-4">
              <img class="addonsimage" src="test2.jpg" />
            </div>
            <div class="col-md-8">
              <h4>This is Heading</h4>
              <p>Price</p>
              <a href="" class="add-on-add-unit">+ Add</a>
            </div>
          </div>

          <div class="row">
            <div class="col-md-12">
              <p class="addonsdesc">Standard photography at best value to turn make lifetime memories from your party. Photographer will be available for maximum 3 hours. 150 - 200 soft copies will be delivered through CD within 10 working days. </p>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="clearme"></div>
    <div class="row">
      <div class="col-md-10" id="showmore">
        <a href="#" class="showmore">+ Show more add-ons</a>
      </div>
    </div>

  </div>


问:
python - large and small dataset comparison
I have 2 pandas dataframes in python. One is very small df1 (<200 rows) and other one is very large df2 (>20M rows). I want to compare the small df with the large one and get all the indexes of larger dataframe df2 for all matching rows.

I have coded the following -

df3 = df2[df2['Row Idx'].isin(df1['Row Idx'])]

In this all the rows of df2 are compared with df1 which is not efficient and the execution is very slow. For 200 rows it takes nearly 30 secs. I have tried to run it in Google Colab and AWS also but the performance is similar.

This comparison is done in a loop for ~400K times as per some condition.

Is there way to improve the performance?

答:
a more efficient way would be to do a join between the dataframes - something like:

df1.merge(df2, on='Row Idx)

see more details here: https://pandas.pydata.org/pandas-docs/stable/user_guide/merging.html

also, pandas has performance issues, especially with large datasets, it might be useful to consider some alternatives like:

modin - faster then pandas, works with the same API so transitioning is simpler

vaex - also works with memory mapped files (not all data is read into memory) which is very significant - but the API is different, so there's a larger learning curve

pyspark

dask


问:
Sequelize - update record, and return result
I am using sequelize with MySQL. For example if I do:

```<code>models.People.update({OwnerId: peopleInfo.newuser},
        {where: {id: peopleInfo.scenario.id}})
        .then(function (result) {
            response(result).code(200);

        }).catch(function (err) {
        request.server.log(['error'], err.stack);
       ).code(200);
    });
</code>```

I am not getting information back if the people model was succesfully updated or not. Variable result is just an array with one element, 0=1

How can I know for certain that the record was updated or not.

答:
If you're using postgres and updating one row.</p>

```<code>  try {
    const result = await MODELNAME.update(req.body, {
      where: { id: req.params.id },
      returning: true
    });
    if (!result) HANDLEERROR()
    const data = result[1][0].get();

    res.status(200).json({ success: true, data });
  } catch (error) {
    HANDLEERROR()
  }
</code>```

Body:
I am using sequelize with MySQL. For example if I do:

models.People.update({OwnerId: peopleInfo.newuser},
        {where: {id: peopleInfo.scenario.id}})
        .then(function (result) {
            response(result).code(200);

        }).catch(function (err) {
        request.server.log(['error'], err.stack);
       ).code(200);
    });

I am not getting information back if the people model was succesfully updated or not. Variable result is just an array with one element, 0=1

How can I know for certain that the record was updated or not.

Body:
If you're using postgres and updating one row.

  try {
    const result = await MODELNAME.update(req.body, {
      where: { id: req.params.id },
      returning: true
    });
    if (!result) HANDLEERROR()
    const data = result[1][0].get();

    res.status(200).json({ success: true, data });
  } catch (error) {
    HANDLEERROR()
  }


问:
How to install openssl 1.1.1 for python 2.7?
I installed python 2.7.17 on a windows 10 machine. I then wanted to test its openssl version by running the following inside python:

```<code>import ssl
print ssl.OPENSSL_VERSION_INFO
</code>```

I am getting (1, 0, 2, 20, 15)
I wanted to upgrade to version 1.1.1.
Doing pip freeze I get:

cffi==1.14.0
cryptography==2.8
enum34==1.1.6
ipaddress==1.0.23
pycparser==2.19
pyOpenSSL==19.1.0
six==1.14.0
```

<p>These seem to be the latest in pip for pyOpenSSL and cryptography.</p>

<p>The openssl I have installed (as part of git bash) is 1.1.1, however, this is not the same version used inside python.</p>

<p>How do I upgrade the version of openssl included in python to 1.1.1 or greater?</p>

<p><strong>EDIT:</strong>
In response to the comments, following is a result of python -m OpenSSL.debug:</p>

```C:\Users\assaf>python -m OpenSSL.debug
pyOpenSSL: 19.1.0
cryptography: 2.8
cffi: 1.14.0
cryptography's compiled against OpenSSL: OpenSSL 1.1.1d  10 Sep 2019
cryptography's linked OpenSSL: OpenSSL 1.1.1d  10 Sep 2019
Pythons's OpenSSL: OpenSSL 1.0.2t  10 Sep 2019
Python executable: C:\Python27\python.exe
Python version: 2.7.17 (v2.7.17:c2f86d86e6, Oct 19 2019, 21:01:17) [MSC v.1500 64 bit (AMD64)]
Platform: win32
sys.path: ['', 'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages']
```

As stated above, cryptography and pyOpenSSL are the latest in pip.

答:
The only way to get Python 2.7 to use the current OpenSSL 1.1.1d version for its ssl module is to rebuild it with that version of OpenSSL. For *nix platforms, this is not too hard; it only involves adjusting some initial configuration files. A quick test on macOS showed that the Python 2.7 source code was actually compatible with the OpenSSL 1.1.1d API so that looked promising.

For Windows however, rebuilding Python 2.7 with OpenSSL 1.1.1d is harder. This is because the build system, which relies on Microsoft's msbuild, is not as easy to adjust as the make-based build system on *nix. You can see the associated Visual Studio solution, projects and property files in Python's PCbuild subdirectory.

Additionally, the differences between the OpenSSL 1.0.2 and 1.1.1 versions is slightly larger on Windows, because library names have changed as well, whereas they have stayed the same for the *nix version.

The required modifications to Python's build system for Windows are not too extensive though. It looks like I was able to achieve what you are looking for, after making the change explained at the bottom of this answer. The actual build can be done with the following command run from Python's PCbuild subdirectory:

```<code>> build --no-tkinter --no-bsddb -e "/p:PlatformToolset=v141"
</code>```

for a 32-bits build, or

```<code>> build --no-tkinter --no-bsddb -e -p x64 "/p:PlatformToolset=v141"
</code>```

for a 64-bits build. The --no- options are used to speed up the process and focus on the OpenSSL aspect. v141 stands for Visual Studio 2017, you need to be in a Visual Studio shell for this to work. After that, the following reproduced your test showing the use of OpenSSL 1.1.1d with Python 2.7.17:

```<code>> win32\python.exe
Python 2.7.17 (tags/v2.7.17-dirty:c2f86d86e6, Feb 20 2020, 01:04:36) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> print ssl.OPENSSL_VERSION
OpenSSL 1.1.1d  10 Sep 2019
</code>```

I did not do any testing beyond this.

In summary, the changes to achieve this include

Removed the libeay project from the solution. This was used to build OpenSSL 1.0.2 from source but it is not compatible with OpenSSL 1.1.1. Instead, the solution now relies on the prebuilt OpenSSL 1.1.1d binaries as provided by the Python repo in cpython-bin-deps. Rebuilding OpenSSL yourself as part of the build process is possible but requires more modifications.

Modified the get_externals.bat batch script to download the OpenSSL 1.1.1d prebuilt libraries from the aforementioned cpython-bin-deps repository.

Modified the openssl.props property file that configures several of the _ssl and _hashlib project settings, and made some changes to those projects themselves as well. The adjustments mostly taken from the v3.8.1 release of Python, to link with the new OpenSSL libraries and set the include paths correctly. With this modification, OpenSSL is no longer statically linked as it used to be in 2.7.17, but dynamically linked.

Applied patches to the files Modules/posixmodule.c and Modules/timemodule.c similar to this patch, to allow for building with Visual Studio 2017 -- the same version the prebuilt OpenSSL binaries are created with.

By the way, more stuff than needed gets downloaded in the current build process, including the OpenSSL and nasm source code. This is only to allow for as few modifications to the original build scripts as possible.

If you are interested in the details, you can check out the associated commit in this fork of the cpython repo which I did just for the purpose of clarifying my answer. It is based on the original tag v2.7.17. You should be able to reproduce the build by checking out that branch v2.7.17_ossl_1.1.1 and running the build command in PCbuild as mentioned above. If enough people are interested, I may clean it up and keep it around.

Body:
I installed python 2.7.17 on a windows 10 machine. I then wanted to test its openssl version by running the following inside python:

import ssl
print ssl.OPENSSL_VERSION_INFO

I am getting (1, 0, 2, 20, 15)
I wanted to upgrade to version 1.1.1.
Doing pip freeze I get:

cffi==1.14.0
cryptography==2.8
enum34==1.1.6
ipaddress==1.0.23
pycparser==2.19
pyOpenSSL==19.1.0
six==1.14.0

These seem to be the latest in pip for pyOpenSSL and cryptography.

The openssl I have installed (as part of git bash) is 1.1.1, however, this is not the same version used inside python.

How do I upgrade the version of openssl included in python to 1.1.1 or greater?

EDIT:
In response to the comments, following is a result of python -m OpenSSL.debug:

C:\Users\assaf>python -m OpenSSL.debug
pyOpenSSL: 19.1.0
cryptography: 2.8
cffi: 1.14.0
cryptography's compiled against OpenSSL: OpenSSL 1.1.1d  10 Sep 2019
cryptography's linked OpenSSL: OpenSSL 1.1.1d  10 Sep 2019
Pythons's OpenSSL: OpenSSL 1.0.2t  10 Sep 2019
Python executable: C:\Python27\python.exe
Python version: 2.7.17 (v2.7.17:c2f86d86e6, Oct 19 2019, 21:01:17) [MSC v.1500 64 bit (AMD64)]
Platform: win32
sys.path: ['', 'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages']

As stated above, cryptography and pyOpenSSL are the latest in pip.

Body:
The only way to get Python 2.7 to use the current OpenSSL 1.1.1d version for its ssl module is to rebuild it with that version of OpenSSL. For *nix platforms, this is not too hard; it only involves adjusting some initial configuration files. A quick test on macOS showed that the Python 2.7 source code was actually compatible with the OpenSSL 1.1.1d API so that looked promising.

For Windows however, rebuilding Python 2.7 with OpenSSL 1.1.1d is harder. This is because the build system, which relies on Microsoft's msbuild, is not as easy to adjust as the make-based build system on *nix. You can see the associated Visual Studio solution, projects and property files in Python's PCbuild subdirectory.

Additionally, the differences between the OpenSSL 1.0.2 and 1.1.1 versions is slightly larger on Windows, because library names have changed as well, whereas they have stayed the same for the *nix version.

The required modifications to Python's build system for Windows are not too extensive though. It looks like I was able to achieve what you are looking for, after making the change explained at the bottom of this answer. The actual build can be done with the following command run from Python's PCbuild subdirectory:

> build --no-tkinter --no-bsddb -e "/p:PlatformToolset=v141"

for a 32-bits build, or

> build --no-tkinter --no-bsddb -e -p x64 "/p:PlatformToolset=v141"

for a 64-bits build. The --no- options are used to speed up the process and focus on the OpenSSL aspect. v141 stands for Visual Studio 2017, you need to be in a Visual Studio shell for this to work. After that, the following reproduced your test showing the use of OpenSSL 1.1.1d with Python 2.7.17:

> win32\python.exe
Python 2.7.17 (tags/v2.7.17-dirty:c2f86d86e6, Feb 20 2020, 01:04:36) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> print ssl.OPENSSL_VERSION
OpenSSL 1.1.1d  10 Sep 2019

I did not do any testing beyond this.

In summary, the changes to achieve this include

Removed the libeay project from the solution. This was used to build OpenSSL 1.0.2 from source but it is not compatible with OpenSSL 1.1.1. Instead, the solution now relies on the prebuilt OpenSSL 1.1.1d binaries as provided by the Python repo in cpython-bin-deps. Rebuilding OpenSSL yourself as part of the build process is possible but requires more modifications.

Modified the get_externals.bat batch script to download the OpenSSL 1.1.1d prebuilt libraries from the aforementioned cpython-bin-deps repository.

Modified the openssl.props property file that configures several of the _ssl and _hashlib project settings, and made some changes to those projects themselves as well. The adjustments mostly taken from the v3.8.1 release of Python, to link with the new OpenSSL libraries and set the include paths correctly. With this modification, OpenSSL is no longer statically linked as it used to be in 2.7.17, but dynamically linked.

Applied patches to the files Modules/posixmodule.c and Modules/timemodule.c similar to this patch, to allow for building with Visual Studio 2017 -- the same version the prebuilt OpenSSL binaries are created with.

By the way, more stuff than needed gets downloaded in the current build process, including the OpenSSL and nasm source code. This is only to allow for as few modifications to the original build scripts as possible.

If you are interested in the details, you can check out the associated commit in this fork of the cpython repo which I did just for the purpose of clarifying my answer. It is based on the original tag v2.7.17. You should be able to reproduce the build by checking out that branch v2.7.17_ossl_1.1.1 and running the build command in PCbuild as mentioned above. If enough people are interested, I may clean it up and keep it around.


问:
Add unique constraint to an existing PostgreSQL index
I have an index in my PostgreSQL 9.3 database:

```<code>CREATE INDEX index_foos_on_bar_and_baz ON foos USING btree (bar, baz);
</code>```

(from a schema migration using Ruby on Rails)

The index is present and made things faster. Now that I've cleaned up duplicate foos, I'd like to make this index unique:

```<code>CREATE UNIQUE INDEX index_foos_on_bar_and_baz ON foos USING btree (bar, baz);
</code>```

Is there a way to alter the existing index and make it unique? Or is it easier/faster to delete the existing index and create a new, unique one?

答:
You can alter an index to add the "UNIQUE" constraint with:

```<code> ALTER TABLE distributors
 ADD CONSTRAINT dist_id_zipcode_key
 UNIQUE (dist_id, zipcode);
</code>```

See the official documentation here: https://www.postgresql.org/docs/current/sql-altertable.html

Body:
I have an index in my PostgreSQL 9.3 database:

CREATE INDEX index_foos_on_bar_and_baz ON foos USING btree (bar, baz);

(from a schema migration using Ruby on Rails)

The index is present and made things faster. Now that I've cleaned up duplicate foos, I'd like to make this index unique:

CREATE UNIQUE INDEX index_foos_on_bar_and_baz ON foos USING btree (bar, baz);

Is there a way to alter the existing index and make it unique? Or is it easier/faster to delete the existing index and create a new, unique one?

Body:
You can alter an index to add the "UNIQUE" constraint with:

 ALTER TABLE distributors
 ADD CONSTRAINT dist_id_zipcode_key
 UNIQUE (dist_id, zipcode);

See the official documentation here: https://www.postgresql.org/docs/current/sql-altertable.html


问:
Does a SOAP Based WCF Service Operation automatically serialize with a Soap Envelope?
I have a WCF Service which returns a list or array.  When it is called by a third party, does it automatically serialize into the proper soap envelope?</p>

答:
Yes it does automatically serialize it, by wrapping it with a SOAP Envelope.

This can be disabled if required.


问:
return type for deployments list using Kubernetes go client
```<code>    package main

    import (
          "fmt"
        "html/template"
        "net/http"
        "os"
        log "github.com/kubernetes/klog"
        "k8s.io/apimachinery/pkg/apis/meta/v1"
        "k8s.io/client-go/kubernetes"
        "k8s.io/client-go/tools/clientcmd"
    )

    type NamespaceDetails struct { //namespace details struct
        Namespace []string
    }

    var templates = template.Must(template.ParseGlob("./*.html"))
    var microservice = "/microservice/"
    var detailed_view = "/detailed/"
    var kube_config_path = os.Getenv("HOME")+"/.kube/config"
    var config, _ = clientcmd.BuildConfigFromFlags("", kube_config_path)
    var clientset,_ = kubernetes.NewForConfig(config)
   var NamespaceClient, _ = clientset.CoreV1().Namespaces().List(v1.ListOptions{})

    func main() {
        http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("css"))))
        http.Handle("/jpeg/", http.StripPrefix("/jpeg/", http.FileServer(http.Dir("css"))))
        http.HandleFunc("/", Homepage)             // calling homepage function at '/' url
        http.HandleFunc(microservice, Deployments) //calling Deployments function at '/microserivce/' url
        http.HandleFunc(detailed_view, DetailedView)
        // http.HandleFunc("/onlyme", onlyme)
        http.ListenAndServe(":8801", nil) // server runs at this port
    }

    func Homepage(w http.ResponseWriter, r *http.Request) {
        NamespaceStruct := NamespaceDetails{}
        for _, Namespaces := range NamespaceClient.Items {
            log.V(5).Info("inside namespace items loop in homepage")
            NamespaceStruct.Namespace = append(NamespaceStruct.Namespace, Namespaces.Name)
        }
                templates.ExecuteTemplate(w, "homepage2.html", NamespaceStruct)
    }

    func deployments(namespace string)(*"k8s.io/api/apps/v1".DeploymentList, error){
        return  clientset.AppsV1().Deployments(namespace).List(v1.ListOptions{})
    }
</code>```

when i am trying to run this code it is giving error:

syntax error: unexpected literal "k8s.io/api/apps/v1", expecting type

i want to return deploymentslist using deploymnets function.i dont know what return type to use so that i succesfully return deployments list.

答:
This is invalid syntax:

```<code>func deployments(namespace string)(*"k8s.io/api/apps/v1".DeploymentList, error){
</code>```

This is the right syntax:

```<code>func deployments(namespace string)(*v1.DeploymentList, error){
</code>```

However, you already have another v1 package imported, so you have to import that package with a different alias, and use that name,

Body:
    package main

    import (
          "fmt"
        "html/template"
        "net/http"
        "os"
        log "github.com/kubernetes/klog"
        "k8s.io/apimachinery/pkg/apis/meta/v1"
        "k8s.io/client-go/kubernetes"
        "k8s.io/client-go/tools/clientcmd"
    )

    type NamespaceDetails struct { //namespace details struct
        Namespace []string
    }

    var templates = template.Must(template.ParseGlob("./*.html"))
    var microservice = "/microservice/"
    var detailed_view = "/detailed/"
    var kube_config_path = os.Getenv("HOME")+"/.kube/config"
    var config, _ = clientcmd.BuildConfigFromFlags("", kube_config_path)
    var clientset,_ = kubernetes.NewForConfig(config)
   var NamespaceClient, _ = clientset.CoreV1().Namespaces().List(v1.ListOptions{})

    func main() {
        http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("css"))))
        http.Handle("/jpeg/", http.StripPrefix("/jpeg/", http.FileServer(http.Dir("css"))))
        http.HandleFunc("/", Homepage)             // calling homepage function at '/' url
        http.HandleFunc(microservice, Deployments) //calling Deployments function at '/microserivce/' url
        http.HandleFunc(detailed_view, DetailedView)
        // http.HandleFunc("/onlyme", onlyme)
        http.ListenAndServe(":8801", nil) // server runs at this port
    }

    func Homepage(w http.ResponseWriter, r *http.Request) {
        NamespaceStruct := NamespaceDetails{}
        for _, Namespaces := range NamespaceClient.Items {
            log.V(5).Info("inside namespace items loop in homepage")
            NamespaceStruct.Namespace = append(NamespaceStruct.Namespace, Namespaces.Name)
        }
                templates.ExecuteTemplate(w, "homepage2.html", NamespaceStruct)
    }

    func deployments(namespace string)(*"k8s.io/api/apps/v1".DeploymentList, error){
        return  clientset.AppsV1().Deployments(namespace).List(v1.ListOptions{})
    }

when i am trying to run this code it is giving error:

syntax error: unexpected literal "k8s.io/api/apps/v1", expecting type

i want to return deploymentslist using deploymnets function.i dont know what return type to use so that i succesfully return deployments list.

Body:
This is invalid syntax:

func deployments(namespace string)(*"k8s.io/api/apps/v1".DeploymentList, error){

This is the right syntax:

func deployments(namespace string)(*v1.DeploymentList, error){

However, you already have another v1 package imported, so you have to import that package with a different alias, and use that name,


问:
Validate a certain column in a csv file data using textfieldparser in c#
I have a button in my webform that uploads a csv file with data, inserts the data in a database, and displays the content of the database in a gridview. I am using a TextFieldParser to read the csv file. However, I cannot seem to figure out how to add a validation in it.

I want to validate the first column (which is the SKU in my database) of the uploaded csv file data. If the data has a duplicate in the database, it will prompt a message that the action cannot be completed. If not, it will continue to insert the data in the database.

This is what the data in the csv file that will be uploaded looks like

For reference, This is my code:

```<code>protected void AddButton_Click(object sender, EventArgs e)
    {

        string path = @"C:\Users\hac9289\Downloads\";
        //Creating object of datatable
        DataTable tblcsv = new DataTable();
        //creating columns
        tblcsv.Columns.Add("Stock Keeping Unit");
        tblcsv.Columns.Add("Universal Product Code");
        tblcsv.Columns.Add("Vendor Name");
        tblcsv.Columns.Add("Product Name");
        tblcsv.Columns.Add("Product Description");
        tblcsv.Columns.Add("Retail Price");
        //getting full file path of Uploaded file
        string CSVFilePath = Path.GetFullPath(path + AddFile.PostedFile.FileName);

        if (!AddFile.HasFile)
        {
            ScriptManager.RegisterStartupScript(this, typeof(string), "Alert", "alert('File Upload Empty');", true);
        }

        else
        {
            //parse records in csv file
            using (TextFieldParser parser = new TextFieldParser(CSVFilePath))
            {
                parser.HasFieldsEnclosedInQuotes = true;
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");
                bool invalid = false;

                while (!parser.EndOfData)
                {
                    //Processing row
                    tblcsv.Rows.Add();
                    int count = 0;
                    string[] fields = parser.ReadFields();

                    /*I am trying these code for validation but it doesnt work hahaha
                    foreach (DataRow row in tblcsv.Rows)
                    {
                        // Check some other column is not equal to some value
                        if (row["StockKeepingUnit"] == fields)
                        {
                            ScriptManager.RegisterStartupScript(this, typeof(string), "Alert", "alert('Action not completed due to duplicate SKU');", true);
                        }
                    }*/

                    foreach (string field in fields)
                    {
                        tblcsv.Rows[tblcsv.Rows.Count - 1][count] = field;

                        count++;
                    }
                }
            }
            InsertCSVRecords(tblcsv);
            PopulateGridView();
        }

    }

    private void InsertCSVRecords(DataTable csvdt)
    {

        using (SqlConnection connect = new SqlConnection(connectionString))
        {
            connect.Open();

            //creating object of SqlBulkCopy
            using (SqlBulkCopy objbulk = new SqlBulkCopy(connect))
            {
                //assigning Destination table name
                objbulk.DestinationTableName = "RetailInfo";
                //Mapping Table column
                objbulk.ColumnMappings.Add(0, "StockKeepingUnit");
                objbulk.ColumnMappings.Add(1, "UniversalProductCode");
                objbulk.ColumnMappings.Add(2, "VendorName");
                objbulk.ColumnMappings.Add(3, "ProductName");
                objbulk.ColumnMappings.Add(4, "ProductDesc");
                objbulk.ColumnMappings.Add(5, "RetailPrice");

                //inserting Datatable Records to DataBase
                objbulk.WriteToServer(csvdt);
            }
        }

        ScriptManager.RegisterStartupScript(this, typeof(string), "Alert", "alert('CSV Data added');", true);

    }
</code>```

Any ideas? Any help will be appreciated. Thank you.

答:
Like this,</p>

```<code> ...

foreach (string field in fields)
{
   // Just here your fields populating in tblcsv's rows. You can check here your field is existing or not.
   // [your_code] : checks field type (or something else) is SKU, after check if exist.
   tblcsv.Rows[tblcsv.Rows.Count - 1][count] = field;

   count++;
}

...
</code>```

Body:
I have a button in my webform that uploads a csv file with data, inserts the data in a database, and displays the content of the database in a gridview. I am using a TextFieldParser to read the csv file. However, I cannot seem to figure out how to add a validation in it.

I want to validate the first column (which is the SKU in my database) of the uploaded csv file data. If the data has a duplicate in the database, it will prompt a message that the action cannot be completed. If not, it will continue to insert the data in the database.

This is what the data in the csv file that will be uploaded looks like

For reference, This is my code:

protected void AddButton_Click(object sender, EventArgs e)
    {

        string path = @"C:\Users\hac9289\Downloads\";
        //Creating object of datatable
        DataTable tblcsv = new DataTable();
        //creating columns
        tblcsv.Columns.Add("Stock Keeping Unit");
        tblcsv.Columns.Add("Universal Product Code");
        tblcsv.Columns.Add("Vendor Name");
        tblcsv.Columns.Add("Product Name");
        tblcsv.Columns.Add("Product Description");
        tblcsv.Columns.Add("Retail Price");
        //getting full file path of Uploaded file
        string CSVFilePath = Path.GetFullPath(path + AddFile.PostedFile.FileName);

        if (!AddFile.HasFile)
        {
            ScriptManager.RegisterStartupScript(this, typeof(string), "Alert", "alert('File Upload Empty');", true);
        }

        else
        {
            //parse records in csv file
            using (TextFieldParser parser = new TextFieldParser(CSVFilePath))
            {
                parser.HasFieldsEnclosedInQuotes = true;
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");
                bool invalid = false;

                while (!parser.EndOfData)
                {
                    //Processing row
                    tblcsv.Rows.Add();
                    int count = 0;
                    string[] fields = parser.ReadFields();

                    /*I am trying these code for validation but it doesnt work hahaha
                    foreach (DataRow row in tblcsv.Rows)
                    {
                        // Check some other column is not equal to some value
                        if (row["StockKeepingUnit"] == fields)
                        {
                            ScriptManager.RegisterStartupScript(this, typeof(string), "Alert", "alert('Action not completed due to duplicate SKU');", true);
                        }
                    }*/

                    foreach (string field in fields)
                    {
                        tblcsv.Rows[tblcsv.Rows.Count - 1][count] = field;

                        count++;
                    }
                }
            }
            InsertCSVRecords(tblcsv);
            PopulateGridView();
        }

    }

    private void InsertCSVRecords(DataTable csvdt)
    {

        using (SqlConnection connect = new SqlConnection(connectionString))
        {
            connect.Open();

            //creating object of SqlBulkCopy
            using (SqlBulkCopy objbulk = new SqlBulkCopy(connect))
            {
                //assigning Destination table name
                objbulk.DestinationTableName = "RetailInfo";
                //Mapping Table column
                objbulk.ColumnMappings.Add(0, "StockKeepingUnit");
                objbulk.ColumnMappings.Add(1, "UniversalProductCode");
                objbulk.ColumnMappings.Add(2, "VendorName");
                objbulk.ColumnMappings.Add(3, "ProductName");
                objbulk.ColumnMappings.Add(4, "ProductDesc");
                objbulk.ColumnMappings.Add(5, "RetailPrice");

                //inserting Datatable Records to DataBase
                objbulk.WriteToServer(csvdt);
            }
        }

        ScriptManager.RegisterStartupScript(this, typeof(string), "Alert", "alert('CSV Data added');", true);

    }

Any ideas? Any help will be appreciated. Thank you.

Body:
Like this,

 ...

foreach (string field in fields)
{
   // Just here your fields populating in tblcsv's rows. You can check here your field is existing or not.
   // [your_code] : checks field type (or something else) is SKU, after check if exist.
   tblcsv.Rows[tblcsv.Rows.Count - 1][count] = field;

   count++;
}

...