# Pattern replace apostrophes?

**URL:** <https://discuss.elastic.co/t/pattern-replace-apostrophes/20113>\
**Category:** Elasticsearch\
**Created:** [October 7, 2014, 1:06pm UTC](https://discuss.elastic.co/t/pattern-replace-apostrophes/20113 "2014-10-07T13:06:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lee\_Gee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lee_gee/32/1217_2.png) [@Lee\_Gee](https://discuss.elastic.co/u/Lee_Gee)\
**Post date:** [October 7, 2014, 1:06pm UTC](https://discuss.elastic.co/t/pattern-replace-apostrophes/20113/1 "2014-10-07T13:06:27Z")

</div>

My users have issues with apostrophes: I need to index and search "aaa's"  
as it is, and without the apostrophe, as "aaas".

If I use a char\_filter to remove apostrophes when indexing and when  
searching, the \_analyze endpoint shows me that they produce 'words' without  
apostrophes like this (respectively):

{... {  
end\_offset =\> 5,  
position =\> 1,  
start\_offset =\> 0,  
token =\> "aaas",  
type =\> "word",  
} }

{  
end\_offset =\> 5,  
position =\> 1,  
start\_offset =\> 0,  
token =\> "aaas",  
type =\> "word",  
},

But there seems to be nothing I can do to find "aaas" / "aaa's" when  
searching!

Is this expected?

TIA  
Lee

--  
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/a959fe9f-6899-47fd-a371-131c1e51071c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a959fe9f-6899-47fd-a371-131c1e51071c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 7, 2014, 7:00pm UTC](https://discuss.elastic.co/t/pattern-replace-apostrophes/20113/2 "2014-10-07T19:00:00Z")

</div>

What type of query are you using? Perhaps the query you are using is not  
using the same analyzer at search time.

--  
Ivan

On Tue, Oct 7, 2014 at 6:06 AM, Lee Gee [leegee@gmail.com](mailto:leegee@gmail.com) wrote:

> My users have issues with apostrophes: I need to index and search "aaa's"  
> as it is, and without the apostrophe, as "aaas".
> 
> If I use a char\_filter to remove apostrophes when indexing and when  
> searching, the \_analyze endpoint shows me that they produce 'words' without  
> apostrophes like this (respectively):
> 
> {... {  
> end\_offset =\> 5,  
> position =\> 1,  
> start\_offset =\> 0,  
> token =\> "aaas",  
> type =\> "word",  
> } }
> 
> {  
> end\_offset =\> 5,  
> position =\> 1,  
> start\_offset =\> 0,  
> token =\> "aaas",  
> type =\> "word",  
> },
> 
> But there seems to be nothing I can do to find "aaas" / "aaa's" when  
> searching!
> 
> Is this expected?
> 
> TIA  
> Lee
> 
> --  
> 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/a959fe9f-6899-47fd-a371-131c1e51071c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a959fe9f-6899-47fd-a371-131c1e51071c%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/a959fe9f-6899-47fd-a371-131c1e51071c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a959fe9f-6899-47fd-a371-131c1e51071c%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CALY%3DcQCOEYRTEuv75sRjh20iYS-tG%2BgBKJp6Dc75AexUkyYetQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCOEYRTEuv75sRjh20iYS-tG%2BgBKJp6Dc75AexUkyYetQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Lee\_Gee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lee_gee/32/1217_2.png) [@Lee\_Gee](https://discuss.elastic.co/u/Lee_Gee)\
**Post date:** [October 8, 2014, 6:18am UTC](https://discuss.elastic.co/t/pattern-replace-apostrophes/20113/3 "2014-10-08T06:18:43Z")

</div>

The index uses the keyword tokenizer, with edge-ngram (and other) filters —  
it only wants to match from the start of the string, for autocomplete.

The search analyser is also keyword, with various filters.

The pattern-replace filter for apostrophes is applied to both.

On Tuesday, October 7, 2014 8:00:13 PM UTC+1, Ivan Brusic wrote:

> What type of query are you using? Perhaps the query you are using is not  
> using the same analyzer at search time.
> 
> --  
> Ivan
> 
> On Tue, Oct 7, 2014 at 6:06 AM, Lee Gee \<[lee...@gmail.com](mailto:lee...@gmail.com) \<javascript:\>\>  
> wrote:
> 
> > My users have issues with apostrophes: I need to index and search "aaa's"  
> > as it is, and without the apostrophe, as "aaas".
> > 
> > If I use a char\_filter to remove apostrophes when indexing and when  
> > searching, the \_analyze endpoint shows me that they produce 'words' without  
> > apostrophes like this (respectively):
> > 
> > {... {  
> > end\_offset =\> 5,  
> > position =\> 1,  
> > start\_offset =\> 0,  
> > token =\> "aaas",  
> > type =\> "word",  
> > } }
> > 
> > {  
> > end\_offset =\> 5,  
> > position =\> 1,  
> > start\_offset =\> 0,  
> > token =\> "aaas",  
> > type =\> "word",  
> > },
> > 
> > But there seems to be nothing I can do to find "aaas" / "aaa's" when  
> > searching!
> > 
> > Is this expected?
> > 
> > TIA  
> > Lee

--  
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/3c5fbb3b-decc-41f6-8be6-2a1f5f37f4be%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3c5fbb3b-decc-41f6-8be6-2a1f5f37f4be%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Lee\_Gee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lee_gee/32/1217_2.png) [@Lee\_Gee](https://discuss.elastic.co/u/Lee_Gee)\
**Post date:** [October 9, 2014, 9:53am UTC](https://discuss.elastic.co/t/pattern-replace-apostrophes/20113/4 "2014-10-09T09:53:59Z")

</div>

The problem was that it was not an apostrophe, but an opening single quote.

Have increased editor font size to address this issue.

On Tuesday, October 7, 2014 8:00:13 PM UTC+1, Ivan Brusic wrote:

> What type of query are you using? Perhaps the query you are using is not  
> using the same analyzer at search time.
> 
> --  
> Ivan
> 
> On Tue, Oct 7, 2014 at 6:06 AM, Lee Gee \<[lee...@gmail.com](mailto:lee...@gmail.com) \<javascript:\>\>  
> wrote:
> 
> > My users have issues with apostrophes: I need to index and search "aaa's"  
> > as it is, and without the apostrophe, as "aaas".
> > 
> > If I use a char\_filter to remove apostrophes when indexing and when  
> > searching, the \_analyze endpoint shows me that they produce 'words' without  
> > apostrophes like this (respectively):
> > 
> > {... {  
> > end\_offset =\> 5,  
> > position =\> 1,  
> > start\_offset =\> 0,  
> > token =\> "aaas",  
> > type =\> "word",  
> > } }
> > 
> > {  
> > end\_offset =\> 5,  
> > position =\> 1,  
> > start\_offset =\> 0,  
> > token =\> "aaas",  
> > type =\> "word",  
> > },
> > 
> > But there seems to be nothing I can do to find "aaas" / "aaa's" when  
> > searching!
> > 
> > Is this expected?
> > 
> > TIA  
> > Lee
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/a959fe9f-6899-47fd-a371-131c1e51071c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a959fe9f-6899-47fd-a371-131c1e51071c%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/a959fe9f-6899-47fd-a371-131c1e51071c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a959fe9f-6899-47fd-a371-131c1e51071c%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/d8e1d1c9-cc1e-49e7-88b8-e767dd2fac08%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d8e1d1c9-cc1e-49e7-88b8-e767dd2fac08%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:57am UTC](https://discuss.elastic.co/t/pattern-replace-apostrophes/20113/5 "2017-07-06T00:57:22Z")

</div>


