# Having trouble when using search strings that have a hash symbol (#) in them

**URL:** <https://discuss.elastic.co/t/having-trouble-when-using-search-strings-that-have-a-hash-symbol-in-them/14826>\
**Category:** Elasticsearch\
**Created:** [December 11, 2013, 11:24pm UTC](https://discuss.elastic.co/t/having-trouble-when-using-search-strings-that-have-a-hash-symbol-in-them/14826 "2013-12-11T23:24:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_Malireddy](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@Rahul\_Malireddy](https://discuss.elastic.co/u/Rahul_Malireddy)\
**Post date:** [December 11, 2013, 11:24pm UTC](https://discuss.elastic.co/t/having-trouble-when-using-search-strings-that-have-a-hash-symbol-in-them/14826/1 "2013-12-11T23:24:22Z")

</div>

Hi,

I am trying to use elasticsearch to index my log files. Some of my  
environment details are given below:

Version of elasticsearch that I am using: 0.90.3  
Version of JVM that I am using: 1.7.0\_17 JVM (64-bit)  
Operating System: Windows Server 2008  
Cluster Health:

- cluster\_name: logstash
- status: yellow
- timed\_out: false
- number\_of\_nodes: 2
- number\_of\_data\_nodes: 1
- active\_primary\_shards: 15
- active\_shards: 15
- relocating\_shards: 0
- initializing\_shards: 0
- unassigned\_shards: 15

Right now, I am in development stage and am playing around with  
elasticsearchto see how it works. I am running into one problem. Some of  
the documents in my index have the hash symbol (#) in them. For Example:  
FlexCubeCash\_001#0103347CAD2203178.000000000. When I query for documents  
that have this string (FlexCubeCash\_001#0103347CAD2203178.000000000) in  
them, it returns all the documents which have the string "FlexCubeCash\_001"  
(in other words text before the hash symbol) in them.

How do I get around this problem? I must be doing some thing wrong. I have  
created a small snippet of code to reproduce the problem your environment.  
This code snippet is in the Gist URL given below:

> <https://gist.github.com/rahul-m/7920182>

As you can see from the code snippet, there is only document that matches  
the search string but I get all three documents back.

If you have any questions or need any other information, please let me  
know, Any help provided will be greatly appreciated.

Thank you.  
Rahul

--  
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/8c57e164-0072-4196-a137-06800704a10c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8c57e164-0072-4196-a137-06800704a10c%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Andrew\_Cholakian\_2](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@Andrew\_Cholakian\_2](https://discuss.elastic.co/u/Andrew_Cholakian_2)\
**Post date:** [December 12, 2013, 3:57am UTC](https://discuss.elastic.co/t/having-trouble-when-using-search-strings-that-have-a-hash-symbol-in-them/14826/2 "2013-12-12T03:57:29Z")

</div>

The problem is that the 'mrisk' analyzer is using the 'standard' tokenizer,  
which splits on non-word text. You can verify this by running:

curl -XPOST '[http://localhost:9200/\_analyze?analyzer=standard](http://localhost:9200/_analyze?analyzer=standard)' -d  
'hello#there'

The output will show that it will split the text on the #. You probably  
want the 'keyword' tokenizer which leaves the source text untouched.

On Wednesday, December 11, 2013 3:24:22 PM UTC-8, Rahul Malireddy wrote:

> Hi,
> 
> I am trying to use elasticsearch to index my log files. Some of my  
> environment details are given below:
> 
> Version of elasticsearch that I am using: 0.90.3  
> Version of JVM that I am using: 1.7.0\_17 JVM (64-bit)  
> Operating System: Windows Server 2008  
> Cluster Health:
> 
> - cluster\_name: logstash
> - status: yellow
> - timed\_out: false
> - number\_of\_nodes: 2
> - number\_of\_data\_nodes: 1
> - active\_primary\_shards: 15
> - active\_shards: 15
> - relocating\_shards: 0
> - initializing\_shards: 0
> - unassigned\_shards: 15
> 
> Right now, I am in development stage and am playing around with  
> elasticsearchto see how it works. I am running into one problem. Some of  
> the documents in my index have the hash symbol (#) in them. For Example:  
> FlexCubeCash\_001#0103347CAD2203178.000000000. When I query for documents  
> that have this string (FlexCubeCash\_001#0103347CAD2203178.000000000) in  
> them, it returns all the documents which have the string "FlexCubeCash\_001"  
> (in other words text before the hash symbol) in them.
> 
> How do I get around this problem? I must be doing some thing wrong. I have  
> created a small snippet of code to reproduce the problem your environment.  
> This code snippet is in the Gist URL given below:
> 
> [Gist that creates a repository to store log messages · GitHub](https://gist.github.com/rahul-m/7920182)
> 
> As you can see from the code snippet, there is only document that matches  
> the search string but I get all three documents back.
> 
> If you have any questions or need any other information, please let me  
> know, Any help provided will be greatly appreciated.
> 
> Thank you.  
> Rahul

--  
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/4396044c-3fa6-4e1f-8e47-56a55ce106d0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4396044c-3fa6-4e1f-8e47-56a55ce106d0%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Rahul\_Malireddy](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@Rahul\_Malireddy](https://discuss.elastic.co/u/Rahul_Malireddy)\
**Post date:** [December 12, 2013, 12:10pm UTC](https://discuss.elastic.co/t/having-trouble-when-using-search-strings-that-have-a-hash-symbol-in-them/14826/3 "2013-12-12T12:10:27Z")

</div>

Thank you.

On Wednesday, December 11, 2013 10:57:29 PM UTC-5, Andrew Cholakian wrote:

> The problem is that the 'mrisk' analyzer is using the 'standard'  
> tokenizer, which splits on non-word text. You can verify this by running:
> 
> curl -XPOST '[http://localhost:9200/\_analyze?analyzer=standard](http://localhost:9200/_analyze?analyzer=standard)' -d  
> 'hello#there'
> 
> The output will show that it will split the text on the #. You probably  
> want the 'keyword' tokenizer which leaves the source text untouched.
> 
> On Wednesday, December 11, 2013 3:24:22 PM UTC-8, Rahul Malireddy wrote:
> 
> > Hi,
> > 
> > I am trying to use elasticsearch to index my log files. Some of my  
> > environment details are given below:
> > 
> > Version of elasticsearch that I am using: 0.90.3  
> > Version of JVM that I am using: 1.7.0\_17 JVM (64-bit)  
> > Operating System: Windows Server 2008  
> > Cluster Health:
> > 
> > - cluster\_name: logstash
> > - status: yellow
> > - timed\_out: false
> > - number\_of\_nodes: 2
> > - number\_of\_data\_nodes: 1
> > - active\_primary\_shards: 15
> > - active\_shards: 15
> > - relocating\_shards: 0
> > - initializing\_shards: 0
> > - unassigned\_shards: 15
> > 
> > Right now, I am in development stage and am playing around with  
> > elasticsearchto see how it works. I am running into one problem. Some of  
> > the documents in my index have the hash symbol (#) in them. For Example:  
> > FlexCubeCash\_001#0103347CAD2203178.000000000. When I query for documents  
> > that have this string (FlexCubeCash\_001#0103347CAD2203178.000000000) in  
> > them, it returns all the documents which have the string "FlexCubeCash\_001"  
> > (in other words text before the hash symbol) in them.
> > 
> > How do I get around this problem? I must be doing some thing wrong. I  
> > have created a small snippet of code to reproduce the problem your  
> > environment. This code snippet is in the Gist URL given below:
> > 
> > [Gist that creates a repository to store log messages · GitHub](https://gist.github.com/rahul-m/7920182)
> > 
> > As you can see from the code snippet, there is only document that matches  
> > the search string but I get all three documents back.
> > 
> > If you have any questions or need any other information, please let me  
> > know, Any help provided will be greatly appreciated.
> > 
> > Thank you.  
> > Rahul

--  
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/92726019-87c0-47b5-946d-5343c5b633e1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/92726019-87c0-47b5-946d-5343c5b633e1%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:01am UTC](https://discuss.elastic.co/t/having-trouble-when-using-search-strings-that-have-a-hash-symbol-in-them/14826/4 "2017-07-06T02:01:39Z")

</div>


