Atributos personalizados (v3)

Cloud Talent Solution ofrece varios atributos de empleo predefinidos para satisfacer las necesidades de distintos clientes. Para obtener el mejor rendimiento de Cloud Talent Solution, te recomendamos que uses los campos predefinidos tanto como sea posible.

Además, Cloud Talent Solution también proporciona atributos personalizados para almacenar información genérica. Los atributos personalizados se usan para ofrecer aún más flexibilidad y permitir que los clientes admitan su lógica empresarial. Los atributos personalizados almacenan información de cadena o numérica, y se pueden filtrar en las consultas de búsqueda configurando los filtros adecuados.

Funciones de atributos personalizados

  • Definir el nombre de un campo personalizado: asigna un nombre a un atributo concreto de un trabajo. Asigna a este atributo el valor "filterable" o "non-filterable" según sea necesario. Normalmente, si la interfaz de usuario necesita una faceta filtrable que no se proporciona de forma predeterminada en Cloud Talent Solution, se puede usar un customAttribute para proporcionar el filtro adecuado.
  • Búsqueda que distingue entre mayúsculas y minúsculas: cada solicitud de búsqueda puede especificar si la búsqueda en todos los atributos personalizados distingue entre mayúsculas y minúsculas.
  • Filtrado por intervalo: los filtros de búsqueda de customAttribute pueden filtrar los trabajos por un intervalo de valores numéricos especificados. Por ejemplo, si se usa un campo customAttribute para almacenar los requisitos mínimos de GPA de un trabajo, el filtro de búsqueda customAttribute se puede usar para devolver trabajos dentro de un determinado intervalo de GPA mínimo, superior a un valor de GPA mínimo, inferior a un valor de GPA mínimo, etc.
  • Filtrado entre campos: customAttribute también ofrece a los clientes de Cloud Talent Solution la posibilidad de definir expresiones que filtren una combinación de atributos personalizados. Por ejemplo, un cliente tiene una lógica empresarial que indica que solo quiere trabajos que patrocinen visados o trabajos a distancia. El cliente almacena ambos campos en un customAttributediferente. El cliente puede especificar un filtro de búsqueda con una expresión que defina la lógica necesaria. Solo se admiten 3 niveles de expresiones anidadas.

  • Búsqueda específica de palabras clave: especifica un customAttribute en el keywordSearchableCustomAttributes de la empresa asociada para asegurarte de que las solicitudes de búsqueda que contengan un valor en el atributo personalizado especificado devuelvan los empleos que contengan ese valor en ese atributo personalizado.

  • Búsquedas basadas en SQL: customAttribute te permite definir expresiones de estilo booleano en la solicitud de búsqueda. Cloud Talent Solution analiza automáticamente estas expresiones, aplica los filtros a la solicitud de búsqueda y devuelve los resultados correspondientes. Solo se permiten 3 niveles de anidación de expresiones booleanas y un máximo de 2000 caracteres.

  • Define contenedores de histogramas personalizados: los atributos personalizados permiten a los clientes de Cloud Talent Solution definir contenedores personalizados con los que se pueden calcular histogramas. Por ejemplo, puedes usar un customAttribute para almacenar información sobre la nota media mínima y, a continuación, crear un histograma de este campo. También puedes crear segmentos de 3,0 a 3,5, de 3,51 a 4,0, etc., para agrupar todas las medias mínimas dentro de estos segmentos.

Usar atributos personalizados

Crea un trabajo con el campo customAttribute (se puede usar con valores numéricos o de cadena):

Java

Para obtener más información sobre cómo instalar y crear un cliente de Cloud Talent Solution, consulta las bibliotecas de cliente de Cloud Talent Solution.


/** Generate a job with a custom attribute. */
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
public static Job generateJobWithACustomAttribute(String companyName) {
  // requisition id should be a unique Id in your system.
  String requisitionId = "jobWithACustomAttribute:" + String.valueOf(new Random().nextLong());
  ApplicationInfo applicationInfo =
      new ApplicationInfo().setUris(Arrays.asList("http://careers.google.com"));

  // Constructs custom attributes map
  Map<String, CustomAttribute> customAttributes = new HashMap<>();
  customAttributes.put(
      "someFieldName1",
      new CustomAttribute().setStringValues(Arrays.asList("value1")).setFilterable(Boolean.TRUE));
  customAttributes.put(
      "someFieldName2",
      new CustomAttribute().setLongValues(Arrays.asList(256L)).setFilterable(true));

  // Creates job with custom attributes
  Job job =
      new Job()
          .setCompanyName(companyName)
          .setRequisitionId(requisitionId)
          .setTitle("Software Engineer")
          .setApplicationInfo(applicationInfo)
          .setDescription("Design, develop, test, deploy, maintain and improve software.")
          .setCustomAttributes(customAttributes);
  System.out.println("Job generated: " + job);
  return job;
}

Python

Para obtener más información sobre cómo instalar y crear un cliente de Cloud Talent Solution, consulta las bibliotecas de cliente de Cloud Talent Solution.

def generate_job_with_custom_attributes(company_name):
    # Requisition id should be a unique Id in your system.
    requisition_id = "job_with_custom_attributes:" + "".join(
        random.choice(string.ascii_uppercase + string.digits) for _ in range(16)
    )

    job_title = "Software Engineer"
    application_urls = ["http://careers.google.com"]
    description = "Design, develop, test, deploy, maintain and improve " "software."

    custom_attributes = {
        "someFieldName1": {"string_values": ["value1"], "filterable": True},
        "someFieldName2": {"long_values": [256], "filterable": True},
    }

    job = {
        "company_name": company_name,
        "requisition_id": requisition_id,
        "title": job_title,
        "application_info": {"uris": application_urls},
        "description": description,
        "custom_attributes": custom_attributes,
    }
    print("Job generated: %s" % job)
    return job

Go

Para obtener más información sobre cómo instalar y crear un cliente de Cloud Talent Solution, consulta las bibliotecas de cliente de Cloud Talent Solution.


// constructJobWithCustomAttributes constructs a job with custom attributes.
func constructJobWithCustomAttributes(companyName string, jobTitle string) *talent.Job {
	// requisitionID shoud be the unique ID in your system
	requisitionID := fmt.Sprintf("job-with-custom-attribute-%d", time.Now().UnixNano())

	job := &talent.Job{
		RequisitionId: requisitionID,
		Title:         jobTitle,
		CompanyName:   companyName,
		ApplicationInfo: &talent.ApplicationInfo{
			Uris: []string{"https://googlesample.com/career"},
		},
		Description: "Design, devolop, test, deploy, maintain and improve software.",
		CustomAttributes: map[string]talent.CustomAttribute{
			"someFieldString": {
				Filterable:   true,
				StringValues: []string{"someStrVal"},
			},
			"someFieldLong": {
				Filterable: true,
				LongValues: []int64{900},
			},
		},
	}
	return job
}

Crea un filtro en el campo customAttribute:

Java

Para obtener más información sobre cómo instalar y crear un cliente de Cloud Talent Solution, consulta las bibliotecas de cliente de Cloud Talent Solution.


/** CustomAttributeFilter on String value CustomAttribute */
public static void filtersOnStringValueCustomAttribute()
    throws IOException, InterruptedException {
  // Make sure to set the requestMetadata the same as the associated search request
  RequestMetadata requestMetadata =
      new RequestMetadata()
          // Make sure to hash your userID
          .setUserId("HashedUserId")
          // Make sure to hash the sessionID
          .setSessionId("HashedSessionID")
          // Domain of the website where the search is conducted
          .setDomain("www.google.com");

  String customAttributeFilter = "NOT EMPTY(someFieldName1)";
  JobQuery jobQuery = new JobQuery().setCustomAttributeFilter(customAttributeFilter);

  SearchJobsRequest searchJobsRequest =
      new SearchJobsRequest()
          .setJobQuery(jobQuery)
          .setRequestMetadata(requestMetadata)
          .setJobView("JOB_VIEW_FULL");
  SearchJobsResponse response =
      talentSolutionClient
          .projects()
          .jobs()
          .search(DEFAULT_PROJECT_ID, searchJobsRequest)
          .execute();
  Thread.sleep(1000);
  System.out.printf("Custom search job results (String value): %s\n", response);
}

Python

Para obtener más información sobre cómo instalar y crear un cliente de Cloud Talent Solution, consulta las bibliotecas de cliente de Cloud Talent Solution.

def custom_attribute_filter_string_value(client_service):
    request_metadata = {
        "user_id": "HashedUserId",
        "session_id": "HashedSessionId",
        "domain": "www.google.com",
    }

    custom_attribute_filter = "NOT EMPTY(someFieldName1)"
    job_query = {"custom_attribute_filter": custom_attribute_filter}
    request = {
        "request_metadata": request_metadata,
        "job_query": job_query,
        "job_view": "JOB_VIEW_FULL",
    }

    response = (
        client_service.projects().jobs().search(parent=parent, body=request).execute()
    )
    print(response)

Go

Para obtener más información sobre cómo instalar y crear un cliente de Cloud Talent Solution, consulta las bibliotecas de cliente de Cloud Talent Solution.


// filterOnStringValueCustomAttribute searches for jobs on a string value custom
// atrribute.
func filterOnStringValueCustomAttribute(w io.Writer, projectID string) (*talent.SearchJobsResponse, error) {
	ctx := context.Background()

	client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
	if err != nil {
		return nil, fmt.Errorf("google.DefaultClient: %w", err)
	}
	// Create the jobs service client.
	service, err := talent.New(client)
	if err != nil {
		return nil, fmt.Errorf("talent.New: %w", err)
	}

	parent := "projects/" + projectID
	req := &talent.SearchJobsRequest{
		JobQuery: &talent.JobQuery{
			CustomAttributeFilter: "NOT EMPTY(someFieldString)",
		},
		// Make sure to set the RequestMetadata the same as the associated
		// search request.
		RequestMetadata: &talent.RequestMetadata{
			// Make sure to hash your userID.
			UserId: "HashedUsrId",
			// Make sure to hash the sessionID.
			SessionId: "HashedSessionId",
			// Domain of the website where the search is conducted.
			Domain: "www.googlesample.com",
		},
		JobView: "JOB_VIEW_FULL",
	}
	resp, err := service.Projects.Jobs.Search(parent, req).Do()
	if err != nil {
		return nil, fmt.Errorf("failed to search for jobs with string value custom attribute: %w", err)
	}

	fmt.Fprintln(w, "Jobs:")
	for _, j := range resp.MatchingJobs {
		fmt.Fprintf(w, "\t%q\n", j.Job.Name)
	}

	return resp, nil
}

Crea otro filtro con customAttribute:

Java

Para obtener más información sobre cómo instalar y crear un cliente de Cloud Talent Solution, consulta las bibliotecas de cliente de Cloud Talent Solution.


/** CustomAttributeFilter on Long value CustomAttribute */
public static void filtersOnLongValueCustomAttribute() throws IOException, InterruptedException {
  // Make sure to set the requestMetadata the same as the associated search request
  RequestMetadata requestMetadata =
      new RequestMetadata()
          // Make sure to hash your userID
          .setUserId("HashedUserId")
          // Make sure to hash the sessionID
          .setSessionId("HashedSessionID")
          // Domain of the website where the search is conducted
          .setDomain("www.google.com");

  String customAttributeFilter = "(255 <= someFieldName2) AND (someFieldName2 <= 257)";
  JobQuery jobQuery = new JobQuery().setCustomAttributeFilter(customAttributeFilter);

  SearchJobsRequest searchJobsRequest =
      new SearchJobsRequest()
          .setJobQuery(jobQuery)
          .setJobView("JOB_VIEW_FULL")
          .setRequestMetadata(requestMetadata);

  SearchJobsResponse response =
      talentSolutionClient
          .projects()
          .jobs()
          .search(DEFAULT_PROJECT_ID, searchJobsRequest)
          .execute();
  Thread.sleep(1000);
  System.out.printf("Custom search job results (Long value): %s\n", response);
}

Python

Para obtener más información sobre cómo instalar y crear un cliente de Cloud Talent Solution, consulta las bibliotecas de cliente de Cloud Talent Solution.

def custom_attribute_filter_long_value(client_service):
    request_metadata = {
        "user_id": "HashedUserId",
        "session_id": "HashedSessionId",
        "domain": "www.google.com",
    }

    custom_attribute_filter = "(255 <= someFieldName2) AND" " (someFieldName2 <= 257)"
    job_query = {"custom_attribute_filter": custom_attribute_filter}
    request = {
        "request_metadata": request_metadata,
        "job_query": job_query,
        "job_view": "JOB_VIEW_FULL",
    }

    response = (
        client_service.projects().jobs().search(parent=parent, body=request).execute()
    )
    print(response)

Go

Para obtener más información sobre cómo instalar y crear un cliente de Cloud Talent Solution, consulta las bibliotecas de cliente de Cloud Talent Solution.


// filterOnLongValueCustomAttribute searches for jobs on a long value custom
// atrribute.
func filterOnLongValueCustomAttribute(w io.Writer, projectID string) (*talent.SearchJobsResponse, error) {
	ctx := context.Background()

	client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
	if err != nil {
		return nil, fmt.Errorf("google.DefaultClient: %w", err)
	}
	// Create the jobs service client.
	service, err := talent.New(client)
	if err != nil {
		return nil, fmt.Errorf("talent.New: %w", err)
	}

	parent := "projects/" + projectID
	req := &talent.SearchJobsRequest{
		JobQuery: &talent.JobQuery{
			CustomAttributeFilter: "someFieldLong < 1000",
		},
		// Make sure to set the RequestMetadata the same as the associated
		// search request.
		RequestMetadata: &talent.RequestMetadata{
			// Make sure to hash your userID.
			UserId: "HashedUsrId",
			// Make sure to hash the sessionID.
			SessionId: "HashedSessionId",
			// Domain of the website where the search is conducted.
			Domain: "www.googlesample.com",
		},
		JobView: "JOB_VIEW_FULL",
	}
	resp, err := service.Projects.Jobs.Search(parent, req).Do()
	if err != nil {
		return nil, fmt.Errorf("failed to search for jobs with long value custom attribute: %w", err)
	}

	fmt.Fprintln(w, "Jobs:")
	for _, j := range resp.MatchingJobs {
		fmt.Fprintf(w, "\t%q\n", j.Job.Name)
	}

	return resp, nil
}

Aproveche los atributos personalizados para facilitar el filtrado entre campos:

En el siguiente ejemplo se muestra cómo definir una solicitud de búsqueda de empleos con una bonificación objetivo de entre el 10% y el 20%, o un empleo que requiera las habilidades de "Gestión de equipos", O un empleo que tenga un valor no vacío en el customAttribute "visa_required".

Java

Para obtener más información sobre cómo instalar y crear un cliente de Cloud Talent Solution, consulta las bibliotecas de cliente de Cloud Talent Solution.


/** CustomAttributeFilter on multiple CustomAttributes */
public static void filtersOnMultiCustomAttributes() throws IOException, InterruptedException {
  // Make sure to set the requestMetadata the same as the associated search request
  RequestMetadata requestMetadata =
      new RequestMetadata()
          // Make sure to hash your userID
          .setUserId("HashedUserId")
          // Make sure to hash the sessionID
          .setSessionId("HashedSessionID")
          // Domain of the website where the search is conducted
          .setDomain("www.google.com");

  String customAttributeFilter =
      "(someFieldName1 = \"value1\") "
          + "AND ((255 <= someFieldName2) OR (someFieldName2 <= 213))";
  JobQuery jobQuery = new JobQuery().setCustomAttributeFilter(customAttributeFilter);

  SearchJobsRequest searchJobsRequest =
      new SearchJobsRequest()
          .setJobQuery(jobQuery)
          .setRequestMetadata(requestMetadata)
          .setJobView("JOB_VIEW_FULL");
  SearchJobsResponse response =
      talentSolutionClient
          .projects()
          .jobs()
          .search(DEFAULT_PROJECT_ID, searchJobsRequest)
          .execute();
  Thread.sleep(1000);
  System.out.printf("Custom search job results (multiple value): %s\n", response);
}

Python

Para obtener más información sobre cómo instalar y crear un cliente de Cloud Talent Solution, consulta las bibliotecas de cliente de Cloud Talent Solution.

def custom_attribute_filter_multi_attributes(client_service):
    request_metadata = {
        "user_id": "HashedUserId",
        "session_id": "HashedSessionId",
        "domain": "www.google.com",
    }

    custom_attribute_filter = (
        '(someFieldName1 = "value1") AND ((255 <= someFieldName2) OR '
        "(someFieldName2 <= 213))"
    )
    job_query = {"custom_attribute_filter": custom_attribute_filter}
    request = {
        "request_metadata": request_metadata,
        "job_query": job_query,
        "job_view": "JOB_VIEW_FULL",
    }

    response = (
        client_service.projects().jobs().search(parent=parent, body=request).execute()
    )
    print(response)

Go

Para obtener más información sobre cómo instalar y crear un cliente de Cloud Talent Solution, consulta las bibliotecas de cliente de Cloud Talent Solution.


// filterOnLongValueCustomAttribute searches for jobs on multiple custom
// atrributes.
func filterOnMultiCustomAttributes(w io.Writer, projectID string) (*talent.SearchJobsResponse, error) {
	ctx := context.Background()

	client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
	if err != nil {
		return nil, fmt.Errorf("google.DefaultClient: %w", err)
	}
	// Create the jobs service client.
	service, err := talent.New(client)
	if err != nil {
		return nil, fmt.Errorf("talent.New: %w", err)
	}

	parent := "projects/" + projectID
	req := &talent.SearchJobsRequest{
		JobQuery: &talent.JobQuery{
			CustomAttributeFilter: "(someFieldString = \"someStrVal\") AND (someFieldLong < 1000)",
		},
		// Make sure to set the RequestMetadata the same as the associated
		// search request.
		RequestMetadata: &talent.RequestMetadata{
			// Make sure to hash your userID.
			UserId: "HashedUsrId",
			// Make sure to hash the sessionID.
			SessionId: "HashedSessionId",
			// Domain of the website where the search is conducted.
			Domain: "www.googlesample.com",
		},
		JobView: "JOB_VIEW_FULL",
	}
	resp, err := service.Projects.Jobs.Search(parent, req).Do()
	if err != nil {
		return nil, fmt.Errorf("failed to search for jobs with multiple custom attributes: %w", err)
	}

	fmt.Fprintln(w, "Jobs:")
	for _, j := range resp.MatchingJobs {
		fmt.Fprintf(w, "\t%q\n", j.Job.Name)
	}

	return resp, nil
}

De forma predeterminada, los endpoints searchJobs y seachJobsForAlert solo buscan en campos predefinidos. Si también necesita buscar en campos customAttribute, use el campo keywordSearchableJobCustomAttributes para definir una lista de atributos personalizados en los que buscar.

Por ejemplo, si un seleccionador quiere usar un customAttribute "customRequisitions" para almacenar los IDs de las solicitudes de empleo de un empleador concreto, puede definir keywordSearchableJobCustomAttributes para que incluya este campo. De esta forma, si el seleccionador realiza una búsqueda normal de "ABC123", se devolverán todos los empleos que tengan el customAttribute "customRequisitions" con el valor "ABC123".