public void searchSample(String phoneNumber) {
    try {
      // Example of phoneNumber format: 4155551212
      String soslQuery =
          "FIND {"
              + phoneNumber
              + "} IN Phone FIELDS "
              + "RETURNING "
              + "Contact(Id, Phone, FirstName, LastName), "
              + "Lead(Id, Phone, FirstName, LastName),"
              + "Account(Id, Phone, Name)";
      // Perform SOSL query
      SearchResult sResult = partnerConnection.search(soslQuery);
      // Get the records returned by the search result
      SearchRecord[] records = sResult.getSearchRecords();
      // Create lists of objects to hold search result records
      List<SObject> contacts = new ArrayList<SObject>();
      List<SObject> leads = new ArrayList<SObject>();
      List<SObject> accounts = new ArrayList<SObject>();

      // Iterate through the search result records
      // and store the records in their corresponding lists
      // based on record type.
      if (records != null && records.length > 0) {
        for (int i = 0; i < records.length; i++) {
          SObject record = records[i].getRecord();
          if (record.getType().toLowerCase().equals("contact")) {
            contacts.add(record);
          } else if (record.getType().toLowerCase().equals("lead")) {
            leads.add(record);
          } else if (record.getType().toLowerCase().equals("account")) {
            accounts.add(record);
          }
        }
        // Display the contacts that the search returned
        if (contacts.size() > 0) {
          System.out.println("Found " + contacts.size() + " contact(s):");
          for (SObject contact : contacts) {
            System.out.println(
                contact.getId()
                    + " - "
                    + contact.getField("FirstName")
                    + " "
                    + contact.getField("LastName")
                    + " - "
                    + contact.getField("Phone"));
          }
        }
        // Display the leads that the search returned
        if (leads.size() > 0) {
          System.out.println("Found " + leads.size() + " lead(s):");
          for (SObject lead : leads) {
            System.out.println(
                lead.getId()
                    + " - "
                    + lead.getField("FirstName")
                    + " "
                    + lead.getField("LastName")
                    + " - "
                    + lead.getField("Phone"));
          }
        }
        // Display the accounts that the search returned
        if (accounts.size() > 0) {
          System.out.println("Found " + accounts.size() + " account(s):");
          for (SObject account : accounts) {
            System.out.println(
                account.getId()
                    + " - "
                    + account.getField("Name")
                    + " - "
                    + account.getField("Phone"));
          }
        }
      } else {
        // The search returned no records
        System.out.println("No records were found for the search.");
      }
    } catch (ConnectionException ce) {
      ce.printStackTrace();
    }
  }