SearchIndexer.java

  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // Licensed under the MIT License.

  3. package com.azure.search.documents.indexes.models;

  4. import com.azure.core.annotation.Fluent;
  5. import com.fasterxml.jackson.annotation.JsonCreator;
  6. import com.fasterxml.jackson.annotation.JsonProperty;
  7. import com.fasterxml.jackson.annotation.JsonSetter;

  8. import java.util.Arrays;
  9. import java.util.List;

  10. /**
  11.  * Represents an indexer.
  12.  */
  13. @Fluent
  14. public final class SearchIndexer {
  15.     /*
  16.      * The name of the indexer.
  17.      */
  18.     @JsonProperty(value = "name", required = true)
  19.     private String name;

  20.     /*
  21.      * The description of the indexer.
  22.      */
  23.     @JsonProperty(value = "description")
  24.     private String description;

  25.     /*
  26.      * The name of the datasource from which this indexer reads data.
  27.      */
  28.     @JsonProperty(value = "dataSourceName", required = true)
  29.     private String dataSourceName;

  30.     /*
  31.      * The name of the skillset executing with this indexer.
  32.      */
  33.     @JsonProperty(value = "skillsetName")
  34.     private String skillsetName;

  35.     /*
  36.      * The name of the index to which this indexer writes data.
  37.      */
  38.     @JsonProperty(value = "targetIndexName", required = true)
  39.     private String targetIndexName;

  40.     /*
  41.      * The schedule for this indexer.
  42.      */
  43.     @JsonProperty(value = "schedule")
  44.     private IndexingSchedule schedule;

  45.     /*
  46.      * Parameters for indexer execution.
  47.      */
  48.     @JsonProperty(value = "parameters")
  49.     private IndexingParameters parameters;

  50.     /*
  51.      * Defines mappings between fields in the data source and corresponding
  52.      * target fields in the index.
  53.      */
  54.     @JsonProperty(value = "fieldMappings")
  55.     private List<FieldMapping> fieldMappings;

  56.     /*
  57.      * Output field mappings are applied after enrichment and immediately
  58.      * before indexing.
  59.      */
  60.     @JsonProperty(value = "outputFieldMappings")
  61.     private List<FieldMapping> outputFieldMappings;

  62.     /*
  63.      * A value indicating whether the indexer is disabled. Default is false.
  64.      */
  65.     @JsonProperty(value = "disabled")
  66.     private Boolean isDisabled;

  67.     /*
  68.      * The ETag of the indexer.
  69.      */
  70.     @JsonProperty(value = "@odata.etag")
  71.     private String eTag;

  72.     /*
  73.      * A description of an encryption key that you create in Azure Key Vault.
  74.      * This key is used to provide an additional level of encryption-at-rest
  75.      * for your indexer definition (as well as indexer execution status) when
  76.      * you want full assurance that no one, not even Microsoft, can decrypt
  77.      * them in Azure Cognitive Search. Once you have encrypted your indexer
  78.      * definition, it will always remain encrypted. Azure Cognitive Search will
  79.      * ignore attempts to set this property to null. You can change this
  80.      * property as needed if you want to rotate your encryption key; Your
  81.      * indexer definition (and indexer execution status) will be unaffected.
  82.      * Encryption with customer-managed keys is not available for free search
  83.      * services, and is only available for paid services created on or after
  84.      * January 1, 2019.
  85.      */
  86.     @JsonProperty(value = "encryptionKey")
  87.     private SearchResourceEncryptionKey encryptionKey;

  88.     /*
  89.      * Adds caching to an enrichment pipeline to allow for incremental
  90.      * modification steps without having to rebuild the index every time.
  91.      */
  92.     @JsonProperty(value = "cache")
  93.     private SearchIndexerCache cache;

  94.     /**
  95.      * Constructor of {@link SearchIndexer}.
  96.      *
  97.      * @param name The name of the indexer.
  98.      */
  99.     public SearchIndexer(String name) {
  100.         this.name = name;
  101.     }

  102.     /**
  103.      * Constructor of {@link SearchIndexer}.
  104.      *
  105.      * @param name The name of the indexer.
  106.      * @param dataSourceName The name of the datasource from which this indexer reads data.
  107.      * @param targetIndexName The name of the index to which this indexer writes data.
  108.      */
  109.     @JsonCreator
  110.     public SearchIndexer(
  111.         @JsonProperty(value = "name") String name,
  112.         @JsonProperty(value = "dataSourceName") String dataSourceName,
  113.         @JsonProperty(value = "targetIndexName") String targetIndexName) {
  114.         this.name = name;
  115.         this.dataSourceName = dataSourceName;
  116.         this.targetIndexName = targetIndexName;
  117.     }

  118.     /**
  119.      * Get the name property: The name of the indexer.
  120.      *
  121.      * @return the name value.
  122.      */
  123.     public String getName() {
  124.         return this.name;
  125.     }

  126.     /**
  127.      * Get the description property: The description of the indexer.
  128.      *
  129.      * @return the description value.
  130.      */
  131.     public String getDescription() {
  132.         return this.description;
  133.     }

  134.     /**
  135.      * Set the description property: The description of the indexer.
  136.      *
  137.      * @param description the description value to set.
  138.      * @return the SearchIndexer object itself.
  139.      */
  140.     public SearchIndexer setDescription(String description) {
  141.         this.description = description;
  142.         return this;
  143.     }

  144.     /**
  145.      * Get the dataSourceName property: The name of the datasource from which
  146.      * this indexer reads data.
  147.      *
  148.      * @return the dataSourceName value.
  149.      */
  150.     public String getDataSourceName() {
  151.         return this.dataSourceName;
  152.     }

  153.     /**
  154.      * Set the dataSourceName property: The name of the datasource from which
  155.      * this indexer reads data.
  156.      *
  157.      * @param dataSourceName the dataSourceName value.
  158.      * @return the SearchIndexer object itself.
  159.      */
  160.     public SearchIndexer setDataSourceName(String dataSourceName) {
  161.         this.dataSourceName = dataSourceName;
  162.         return this;
  163.     }

  164.     /**
  165.      * Get the skillsetName property: The name of the skillset executing with
  166.      * this indexer.
  167.      *
  168.      * @return the skillsetName value.
  169.      */
  170.     public String getSkillsetName() {
  171.         return this.skillsetName;
  172.     }

  173.     /**
  174.      * Set the skillsetName property: The name of the skillset executing with
  175.      * this indexer.
  176.      *
  177.      * @param skillsetName the skillsetName value to set.
  178.      * @return the SearchIndexer object itself.
  179.      */
  180.     public SearchIndexer setSkillsetName(String skillsetName) {
  181.         this.skillsetName = skillsetName;
  182.         return this;
  183.     }

  184.     /**
  185.      * Get the targetIndexName property: The name of the index to which this
  186.      * indexer writes data.
  187.      *
  188.      * @return the targetIndexName value.
  189.      */
  190.     public String getTargetIndexName() {
  191.         return this.targetIndexName;
  192.     }

  193.     /**
  194.      * Set the targetIndexName property: The name of the index to which this
  195.      * indexer writes data.
  196.      *
  197.      * @param targetIndexName the targetIndexName value.
  198.      * @return the SearchIndexer object itself.
  199.      */
  200.     public SearchIndexer setTargetIndexName(String targetIndexName) {
  201.         this.targetIndexName = targetIndexName;
  202.         return this;
  203.     }

  204.     /**
  205.      * Get the schedule property: The schedule for this indexer.
  206.      *
  207.      * @return the schedule value.
  208.      */
  209.     public IndexingSchedule getSchedule() {
  210.         return this.schedule;
  211.     }

  212.     /**
  213.      * Set the schedule property: The schedule for this indexer.
  214.      *
  215.      * @param schedule the schedule value to set.
  216.      * @return the SearchIndexer object itself.
  217.      */
  218.     public SearchIndexer setSchedule(IndexingSchedule schedule) {
  219.         this.schedule = schedule;
  220.         return this;
  221.     }

  222.     /**
  223.      * Get the parameters property: Parameters for indexer execution.
  224.      *
  225.      * @return the parameters value.
  226.      */
  227.     public IndexingParameters getParameters() {
  228.         return this.parameters;
  229.     }

  230.     /**
  231.      * Set the parameters property: Parameters for indexer execution.
  232.      *
  233.      * @param parameters the parameters value to set.
  234.      * @return the SearchIndexer object itself.
  235.      */
  236.     public SearchIndexer setParameters(IndexingParameters parameters) {
  237.         this.parameters = parameters;
  238.         return this;
  239.     }

  240.     /**
  241.      * Get the fieldMappings property: Defines mappings between fields in the
  242.      * data source and corresponding target fields in the index.
  243.      *
  244.      * @return the fieldMappings value.
  245.      */
  246.     public List<FieldMapping> getFieldMappings() {
  247.         return this.fieldMappings;
  248.     }

  249.     /**
  250.      * Set the fieldMappings property: Defines mappings between fields in the
  251.      * data source and corresponding target fields in the index.
  252.      *
  253.      * @param fieldMappings the fieldMappings value to set.
  254.      * @return the SearchIndexer object itself.
  255.      */
  256.     public SearchIndexer setFieldMappings(FieldMapping... fieldMappings) {
  257.         this.fieldMappings = (fieldMappings == null) ? null : Arrays.asList(fieldMappings);
  258.         return this;
  259.     }

  260.     /**
  261.      * Set the fieldMappings property: Defines mappings between fields in the
  262.      * data source and corresponding target fields in the index.
  263.      *
  264.      * @param fieldMappings the fieldMappings value to set.
  265.      * @return the SearchIndexer object itself.
  266.      */
  267.     @JsonSetter
  268.     public SearchIndexer setFieldMappings(List<FieldMapping> fieldMappings) {
  269.         this.fieldMappings = fieldMappings;
  270.         return this;
  271.     }

  272.     /**
  273.      * Get the outputFieldMappings property: Output field mappings are applied
  274.      * after enrichment and immediately before indexing.
  275.      *
  276.      * @return the outputFieldMappings value.
  277.      */
  278.     public List<FieldMapping> getOutputFieldMappings() {
  279.         return this.outputFieldMappings;
  280.     }

  281.     /**
  282.      * Set the outputFieldMappings property: Output field mappings are applied
  283.      * after enrichment and immediately before indexing.
  284.      *
  285.      * @param outputFieldMappings the outputFieldMappings value to set.
  286.      * @return the SearchIndexer object itself.
  287.      */
  288.     public SearchIndexer setOutputFieldMappings(FieldMapping... outputFieldMappings) {
  289.         this.outputFieldMappings = (outputFieldMappings == null) ? null : Arrays.asList(outputFieldMappings);
  290.         return this;
  291.     }

  292.     /**
  293.      * Set the outputFieldMappings property: Output field mappings are applied
  294.      * after enrichment and immediately before indexing.
  295.      *
  296.      * @param outputFieldMappings the outputFieldMappings value to set.
  297.      * @return the SearchIndexer object itself.
  298.      */
  299.     @JsonSetter
  300.     public SearchIndexer setOutputFieldMappings(List<FieldMapping> outputFieldMappings) {
  301.         this.outputFieldMappings = outputFieldMappings;
  302.         return this;
  303.     }

  304.     /**
  305.      * Get the isDisabled property: A value indicating whether the indexer is
  306.      * disabled. Default is false.
  307.      *
  308.      * @return the isDisabled value.
  309.      */
  310.     public Boolean isDisabled() {
  311.         return this.isDisabled;
  312.     }

  313.     /**
  314.      * Set the isDisabled property: A value indicating whether the indexer is
  315.      * disabled. Default is false.
  316.      *
  317.      * @param isDisabled the isDisabled value to set.
  318.      * @return the SearchIndexer object itself.
  319.      */
  320.     public SearchIndexer setIsDisabled(Boolean isDisabled) {
  321.         this.isDisabled = isDisabled;
  322.         return this;
  323.     }

  324.     /**
  325.      * Get the eTag property: The ETag of the indexer.
  326.      *
  327.      * @return the eTag value.
  328.      */
  329.     public String getETag() {
  330.         return this.eTag;
  331.     }

  332.     /**
  333.      * Set the eTag property: The ETag of the indexer.
  334.      *
  335.      * @param eTag the eTag value to set.
  336.      * @return the SearchIndexer object itself.
  337.      */
  338.     public SearchIndexer setETag(String eTag) {
  339.         this.eTag = eTag;
  340.         return this;
  341.     }

  342.     /**
  343.      * Get the encryptionKey property: A description of an encryption key that you create in Azure Key Vault. This key
  344.      * is used to provide an additional level of encryption-at-rest for your indexer definition (as well as indexer
  345.      * execution status) when you want full assurance that no one, not even Microsoft, can decrypt them in Azure
  346.      * Cognitive Search. Once you have encrypted your indexer definition, it will always remain encrypted. Azure
  347.      * Cognitive Search will ignore attempts to set this property to null. You can change this property as needed if you
  348.      * want to rotate your encryption key; Your indexer definition (and indexer execution status) will be unaffected.
  349.      * Encryption with customer-managed keys is not available for free search services, and is only available for paid
  350.      * services created on or after January 1, 2019.
  351.      *
  352.      * @return the encryptionKey value.
  353.      */
  354.     public SearchResourceEncryptionKey getEncryptionKey() {
  355.         return this.encryptionKey;
  356.     }

  357.     /**
  358.      * Set the encryptionKey property: A description of an encryption key that you create in Azure Key Vault. This key
  359.      * is used to provide an additional level of encryption-at-rest for your indexer definition (as well as indexer
  360.      * execution status) when you want full assurance that no one, not even Microsoft, can decrypt them in Azure
  361.      * Cognitive Search. Once you have encrypted your indexer definition, it will always remain encrypted. Azure
  362.      * Cognitive Search will ignore attempts to set this property to null. You can change this property as needed if you
  363.      * want to rotate your encryption key; Your indexer definition (and indexer execution status) will be unaffected.
  364.      * Encryption with customer-managed keys is not available for free search services, and is only available for paid
  365.      * services created on or after January 1, 2019.
  366.      *
  367.      * @param encryptionKey the encryptionKey value to set.
  368.      * @return the SearchIndexer object itself.
  369.      */
  370.     public SearchIndexer setEncryptionKey(SearchResourceEncryptionKey encryptionKey) {
  371.         this.encryptionKey = encryptionKey;
  372.         return this;
  373.     }

  374.     /**
  375.      * Get the cache property: Adds caching to an enrichment pipeline to allow for incremental modification steps
  376.      * without having to rebuild the index every time.
  377.      *
  378.      * @return the cache value.
  379.      */
  380.     public SearchIndexerCache getCache() {
  381.         return this.cache;
  382.     }

  383.     /**
  384.      * Set the cache property: Adds caching to an enrichment pipeline to allow for incremental modification steps
  385.      * without having to rebuild the index every time.
  386.      *
  387.      * @param cache the cache value to set.
  388.      * @return the SearchIndexer object itself.
  389.      */
  390.     public SearchIndexer setCache(SearchIndexerCache cache) {
  391.         this.cache = cache;
  392.         return this;
  393.     }
  394. }