title: Masking sensitive data when indexing in spring boot hibernate search
body: <p>I am using spring boot 2.0.2 and hibernate search version 5.10.2.
  I have the following class as my entity:</p>
  
  <pre><code>    @Entity
      @Table(name = "CUSTOMERS")
      @Indexed(index = "indexes_customer")
      @JsonIgnoreProperties(ignoreUnknown = true)
      public class Beneficiary implements Serializable {
          private static final long serialVersionUID = 1L;
          @Id
          @Column(name = "ID", nullable = false)
          @GeneratedValue(strategy = GenerationType.IDENTITY)
          private long id;
  
          @Basic
          @Column(name = "CARD_NUMBER", length = 18)
          @Field(analyze = Analyze.NO, store = Store.YES)
          @SortableField
          private String cardNumber;
  
          @Basic
          @Column(name = "FULL_NAME", length = 60)
          @Field(analyze = Analyze.NO, store = Store.YES)
          @SortableField
          private String fullName;
          //Getters &amp; setters
  </code></pre>
  
  <p>The card data is persisted in plain text but masked when displaying to fronted users. However, i would like to mask card numbers when indexing.
  Currently, my index looks like this:</p>
  
  <pre><code>{
    "_index": "indexes_customer",
    "_type": "mypackage.Customer",
    "_id": "24",
    "_version": 3,
    "_score": 1,
    "_source": {
      "id": "24",
      "name": "Customer Name",
      "cardNumber": "1234567891011"
    }
  }
  </code></pre>
  
  <p>I would like it to look more like this:</p>
  
  <pre><code>{
    "_index": "indexes_customer",
    "_type": "mypackage.Customer",
    "_id": "24",
    "_version": 3,
    "_score": 1,
    "_source": {
      "id": "24",
      "name": "Customer Name",
      "cardNumber": "1234******1011"
    }
  }
  </code></pre>
  
  <p>Thanks</p>