क्वेरी के नतीजों की गिनती करना

एक्सपोर्ट बनाने से पहले, Gmail या Groups क्वेरी के मैसेज की गिनती करने के लिए, matters.count तरीके का इस्तेमाल किया जा सकता है. इस जानकारी की मदद से, क्वेरी फ़िल्टर को बेहतर बनाया जा सकता है, ताकि ज़्यादा या कम नतीजे मिल सकें.

Vault के संसाधनों का इस्तेमाल करने के लिए, आपके खाते के पास Vault के ज़रूरी ऐक्सेस और मामले का ऐक्सेस होना चाहिए. किसी मामले को ऐक्सेस करने के लिए, ज़रूरी है कि खाते ने वह मामला बनाया हो, उसने वह मामला शेयर किया हो या उसके पास सभी मामले देखें की अनुमति हो.

यहां दिए गए उदाहरण में, उन मैसेज के लिए क्वेरी से मिले नतीजों की गिनती करने का तरीका बताया गया है जो इन शर्तों को पूरा करते हैं:

  • email1 और email2 के मालिकाना हक वाले मैसेज.
  • इसमें ड्राफ़्ट में मौजूद मैसेज शामिल नहीं होते.
  • ceo@solarmora.com को भेजे गए मैसेज.
JavaPython
public Long count(Vault client, String matterId) {
  AccountInfo emailsToSearch = new AccountInfo().setEmails(ImmutableList.of("email1", "email2"));
  MailOptions mailQueryOptions = new MailOptions().setExcludeDrafts(true);
  String queryTerms = "to:ceo@solarmora.com";
  Query query =
    new Query()
      .setCorpus("MAIL")
      .setDataScope("ALL_DATA")
      .setSearchMethod("ACCOUNT")
      .setAccountInfo(emailsToSearch)
      .setTerms(queryTerms);
  CountArtifactsRequest request = new CountArtifactsRequest().setQuery(query);
  Operation operation = client.matters().count(matterId, request).execute();

  while(!operation.getDone()) {
    sleep(2000);
    operation = service.operations().get(operation.getName()).execute();
  }
  if(operation.getResponse() != null) {
    return Long.parseLong(operation.getResponse.get("total_count").toString());
  }
  return -1;
}
 
def count(service, matter_id):
  emails_to_search = ['email1', 'email2']
  mail_query_options = {'excludeDrafts': True}
  query_terms = 'to:ceo@solarmora.com'
  mail_query = {
    'corpus': 'MAIL',
    'dataScope': 'ALL_DATA',
    'searchMethod': 'ACCOUNT',
    'accountInfo': {
        'emails': emails_to_search
    },
    'terms': query_terms,
    'mailOptions': mail_query_options,
  }
  request = {
    'query': mail_query
  }
  operation = service.matters().count(matterId=matter_id, body=request).execute()

  while not operation.getDone():
    time.sleep(2)
    operation = service.operations().get(name=operation.getName()).execute()

  if operation.getResponse() is None:
    return -1

  return operation.getResponse()["total_count"]