# Changing the analyzer used by @FullTextField by default

**URL:** <https://discourse.hibernate.org/t/changing-the-analyzer-used-by-fulltextfield-by-default/5726>\
**Category:** Hibernate Search\
**Created:** [September 22, 2021, 5:57pm UTC](https://discourse.hibernate.org/t/changing-the-analyzer-used-by-fulltextfield-by-default/5726 "2021-09-22T17:57:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dimitri](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/dimitri/32/513_2.png) [@Dimitri](https://discourse.hibernate.org/u/Dimitri)\
**Post date:** [September 22, 2021, 5:57pm UTC](https://discourse.hibernate.org/t/changing-the-analyzer-used-by-fulltextfield-by-default/5726/1 "2021-09-22T17:57:52Z")

</div>

[Moderator note: topic moved from [Hibernate Search 6 doesn't support BigDecimal primary keys?](https://discourse.hibernate.org/t/hibernate-search-6-doesnt-support-bigdecimal-primary-keys/5712/)]

Thanks. It works now when I just use @DocumentId.

Is there also a way I give @FullTextField the same global treatment?

I.e., can I configure Hibernate Search 6 to always you a specific analyzer (we use only one analyzer in our application) rather than being forced to duplicate the same analyzer string name in every annotation?

E.g., I’d like to do this:

```auto
...
@FullTextField private String foo;
@FullTextField private String bar;
...

```

rather than this:

```auto
...
@FullTextField(analyzer = "myAnalyzer") private String foo;
@FullTextField(analyzer = "myAnalyzer") private String bar;
...

```

---

<div class="post-metadata">

**Author:** ![yrodiere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/yrodiere/32/1760_2.png) [@yrodiere](https://discourse.hibernate.org/u/yrodiere)\
**Post date:** [September 23, 2021, 7:09am UTC](https://discourse.hibernate.org/t/changing-the-analyzer-used-by-fulltextfield-by-default/5726/2 "2021-09-23T07:09:04Z")

</div>

> [@Dimitri](#):
>
> I.e., can I configure Hibernate Search 6 to always you a specific analyzer (we use only one analyzer in our application) rather than being forced to duplicate the same analyzer string name in every annotation?

You can override the default analyzer, which is the one used by `@FullTextField` when you don’t specify the analyzer.

To override the default analyzer, just define a custom analyzer whose name is `default` (you can use the constant `AnalyzerNames.DEFAULT`).

Something like this:

```java
public class MyLuceneAnalysisConfigurer implements LuceneAnalysisConfigurer {
    @Override
    public void configure(LuceneAnalysisConfigurationContext context) {
        context.analyzer( AnalyzerNames.DEFAULT ).custom() 
                .tokenizer( StandardTokenizerFactory.class ) 
                .charFilter( HTMLStripCharFilterFactory.class ) 
                .tokenFilter( LowerCaseFilterFactory.class ) 
                .tokenFilter( SnowballPorterFilterFactory.class ) 
                        .param( "language", "English" ) 
                .tokenFilter( ASCIIFoldingFilterFactory.class );
    }
}

```

Or like this for Elasticsearch:

```java
public class MyElasticsearchAnalysisConfigurer implements ElasticsearchAnalysisConfigurer {
    @Override
    public void configure(ElasticsearchAnalysisConfigurationContext context) {
        context.analyzer( AnalyzerNames.DEFAULT ).custom() 
                .tokenizer( "standard" ) 
                .charFilters( "html_strip" ) 
                .tokenFilters( "lowercase", "snowball_english", "asciifolding" ); 

        context.tokenFilter( "snowball_english" ) 
                .type( "snowball" )
                .param( "language", "English" );
    }
}

```

For more information about built-in analyzer, including the default one, see [this section of the documentation for Lucene](https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#backend-lucene-analysis-builtin), or [this one for Elasticsearch](https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#backend-elasticsearch-analysis-builtin).

For more information about defining custom analyzers, see [this section of the documentation for Lucene](https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#backend-lucene-analysis-analyzers), or [this one for Elasticsearch](https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#backend-elasticsearch-analysis-analyzers).
