# Hash tag field analyzer not being applied

**URL:** <https://discuss.elastic.co/t/hash-tag-field-analyzer-not-being-applied/18304>\
**Category:** Elasticsearch\
**Created:** [June 24, 2014, 5:50pm UTC](https://discuss.elastic.co/t/hash-tag-field-analyzer-not-being-applied/18304 "2014-06-24T17:50:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andre\_Morais](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@Andre\_Morais](https://discuss.elastic.co/u/Andre_Morais)\
**Post date:** [June 24, 2014, 5:50pm UTC](https://discuss.elastic.co/t/hash-tag-field-analyzer-not-being-applied/18304/1 "2014-06-24T17:50:52Z")

</div>

Hello!

```
I have configured an analyzer in my YML to exclude all words that do 

```

not start with either # or @ to process hash tags and at tags. This  
analyzer works fine if using the analyzer API but when I index data it is  
not being applied.

```
I thought that when indexing, analyzers would replace the original 

```

contents with the analysis result. Is that not so?

```
Thank you for your help!

      André

```

* * *

```
Here is my YML configuration:

```

index.analysis.analyzer.tags:  
type: custom  
tokenizer: whitespace  
filter: fntags, fnsize  
index.analysis.filter.fntags:  
type : pattern\_replace  
pattern: "^[^#@]+.\*$"  
replacement: ""  
index.analysis.filter.fnsize:  
type : length  
min : 2  
max : 200

Here is my type mapping for the field:

Hash\_Tags: {  
analyzer: tags  
type: string  
}

Here is the result when using the analyzer API:

curl -XGET 'localhost:9200/catalog/\_analyze?field=Hash\_Tags&pretty=true' -d  
'NO a la violencia! Comparta esto en la medida de lo posible si espera  
verdaderamente un mejor mundo para Navidad... y despus! #lifeworthbetter'  
{  
"tokens" : [ {  
"token" : "#lifeworthbetter",  
"start\_offset" : 126,  
"end\_offset" : 142,  
"type" : "word",  
"position" : 23  
} ]  
}

And here the result for a match\_all query:

Hash\_Tags: " NO a la violencia! Comparta esto en la medida de lo posible si  
espera verdaderamente un mejor mundo para Navidad... y después!  
#lifeworthbetter"

I was expecting:  
Hash\_Tags: "#lifeworthbetter"

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b719f38f-c8a0-439f-9cdc-0bf3f709429d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b719f38f-c8a0-439f-9cdc-0bf3f709429d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Andre\_Morais](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@Andre\_Morais](https://discuss.elastic.co/u/Andre_Morais)\
**Post date:** [June 25, 2014, 9:42am UTC](https://discuss.elastic.co/t/hash-tag-field-analyzer-not-being-applied/18304/2 "2014-06-25T09:42:33Z")

</div>

Figured it out... Analyzer is correct but, contrary to what I thought, all  
the data I put in the index is stored there and the analyzer is only  
applied when indexing or querying it. So, retrieving my hashtag field data  
should return all the data I put there and not merely the tokens resulting  
from data analysis with my analyzer.

```
   Thanks anyway!

```

Terça-feira, 24 de Junho de 2014 18:50:53 UTC+1, André Morais escreveu:

> Hello!
> 
> ```
> I have configured an analyzer in my YML to exclude all words that do 
> 
> ```
> 
> not start with either # or @ to process hash tags and at tags. This  
> analyzer works fine if using the analyzer API but when I index data it is  
> not being applied.
> 
> ```
> I thought that when indexing, analyzers would replace the original 
> 
> ```
> 
> contents with the analysis result. Is that not so?
> 
> ```
> Thank you for your help!
> 
> André
> 
> ```
> 
> * * *
> 
> ```
> Here is my YML configuration:
> 
> ```
> 
> index.analysis.analyzer.tags:  
> type: custom  
> tokenizer: whitespace  
> filter: fntags, fnsize  
> index.analysis.filter.fntags:  
> type : pattern\_replace  
> pattern: "\[1\]+.\*$"  
> replacement: ""  
> index.analysis.filter.fnsize:  
> type : length  
> min : 2  
> max : 200
> 
> Here is my type mapping for the field:
> 
> Hash\_Tags: {  
> analyzer: tags  
> type: string  
> }
> 
> Here is the result when using the analyzer API:
> 
> curl -XGET 'localhost:9200/catalog/\_analyze?field=Hash\_Tags&pretty=true'  
> -d 'NO a la violencia! Comparta esto en la medida de lo posible si espera  
> verdaderamente un mejor mundo para Navidad... y despus! #lifeworthbetter'  
> {  
> "tokens" : [ {  
> "token" : "#lifeworthbetter",  
> "start\_offset" : 126,  
> "end\_offset" : 142,  
> "type" : "word",  
> "position" : 23  
> } ]  
> }
> 
> And here the result for a match\_all query:
> 
> Hash\_Tags: " NO a la violencia! Comparta esto en la medida de lo posible  
> si espera verdaderamente un mejor mundo para Navidad... y después!  
> #lifeworthbetter"
> 
> I was expecting:  
> Hash\_Tags: "#lifeworthbetter"

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e3330517-750e-4895-bc8a-6cef8249c89d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e3330517-750e-4895-bc8a-6cef8249c89d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

* * *

1. ^#@

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:19am UTC](https://discuss.elastic.co/t/hash-tag-field-analyzer-not-being-applied/18304/3 "2017-07-06T01:19:54Z")

</div>


