Search code examples
hibernate-search

Hibernate Search - Disable _source


I am using Postgres database and Hibernate Search (6.0.3) with Elastic Search(ES) backend. I want to store only the index in ES, by default Hibernate Search is also storing the data for the indexed fields (in _source).

How to create an index in Hibernate Search (for Elasticsearch backend) without the data (_source)?


Solution

  • EDIT: Disabling the _source field from Hibernate Search configuration is possible starting with Hibernate Search 6.1.0.Beta1: https://docs.jboss.org/hibernate/search/6.1/reference/en-US/html_single/#_custom_index_mapping


    Old answer for Hibernate Search 6.0 only:

    If you mean disabling the _source field, there is no built-in feature for that in Hibernate Search at the moment.

    You could disable automatic index creation and create the indexes and their mappings yourself, with mappings._source set to false, but that would be unpleasant as that would require listing every single field in your index.

    It should be possible to add a setting in Hibernate Search itself to disable the source in the indexes it creates, much like the existing setting to mark the mapping as dynamic. It probably won't be too hard since Hibernate Search itself doesn't rely directly on the source (except for projections, but you may not need them).

    I encourage you to open a ticket if you want such a setting.