# Need help to apply Analyzers

**URL:** <https://discuss.elastic.co/t/need-help-to-apply-analyzers/8323>\
**Category:** Elasticsearch\
**Created:** [July 5, 2012, 8:41am UTC](https://discuss.elastic.co/t/need-help-to-apply-analyzers/8323 "2012-07-05T08:41:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aps](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@aps](https://discuss.elastic.co/u/aps)\
**Post date:** [July 5, 2012, 8:41am UTC](https://discuss.elastic.co/t/need-help-to-apply-analyzers/8323/1 "2012-07-05T08:41:09Z")

</div>

Hi,

We are indexing data which has various fields like Address, Phone Number,  
Street Number etc. The problem which we are facing is Address field has  
data space separated for .e.g "Oak Avenue", "Pretoria Avenue", "B Street",  
"A Street" etc.

When we search for Pretoria Avenue it gives all set of documents which has  
Pretoria as well as Avenue. But we need specific search to Pretoria Avenue  
only.

Same problem with Phone Number and Street Number it has data with "-", "."  
characters, and the document separate the data into 2 whenever it has "-" .

How and which analyzers we should use to get proper and specific results in  
that case?

Any help would be appreciated.

Thanks in advanced.

---

<div class="post-metadata">

**Author:** ![Shaun\_Farrell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaun_farrell/32/2827_2.png) [@Shaun\_Farrell](https://discuss.elastic.co/u/Shaun_Farrell)\
**Post date:** [July 5, 2012, 12:27pm UTC](https://discuss.elastic.co/t/need-help-to-apply-analyzers/8323/2 "2012-07-05T12:27:28Z")

</div>

In your mapping you can put

"index" : "not\_analyzed"

You can can also do this through your custom analyzer if you have one  
of those too.

Not Analyzed will not tokenize the string at all. The only issue I  
would see in your senerio is if i searched for "Oak Ave" that wouldn't  
come back. You might need to setup some synonyms or create a custom  
analyzer.

Shaun Farrell

On Thu, Jul 5, 2012 at 4:41 AM, aps [pushkardkumar@gmail.com](mailto:pushkardkumar@gmail.com) wrote:

> Hi,
> 
> We are indexing data which has various fields like Address, Phone Number,  
> Street Number etc. The problem which we are facing is Address field has data  
> space separated for .e.g "Oak Avenue", "Pretoria Avenue", "B Street", "A  
> Street" etc.
> 
> When we search for Pretoria Avenue it gives all set of documents which has  
> Pretoria as well as Avenue. But we need specific search to Pretoria Avenue  
> only.
> 
> Same problem with Phone Number and Street Number it has data with "-", "."  
> characters, and the document separate the data into 2 whenever it has "-" .
> 
> How and which analyzers we should use to get proper and specific results in  
> that case?
> 
> Any help would be appreciated.
> 
> Thanks in advanced.

---

<div class="post-metadata">

**Author:** ![aps](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@aps](https://discuss.elastic.co/u/aps)\
**Post date:** [July 5, 2012, 1:52pm UTC](https://discuss.elastic.co/t/need-help-to-apply-analyzers/8323/3 "2012-07-05T13:52:26Z")

</div>

Thanks for the prompt response. Use of synonyms could be difficult because  
the data is huge and we cannot predict the data in advance.

We will look into custom analyzers for this, because we need documents to  
be searchable if I write only "pretoria".

On Thursday, 5 July 2012 14:27:28 UTC+2, Shaun Farrell wrote:

> In your mapping you can put
> 
> "index" : "not\_analyzed"
> 
> You can can also do this through your custom analyzer if you have one  
> of those too.
> 
> Not Analyzed will not tokenize the string at all. The only issue I  
> would see in your senerio is if i searched for "Oak Ave" that wouldn't  
> come back. You might need to setup some synonyms or create a custom  
> analyzer.
> 
> Shaun Farrell
> 
> On Thu, Jul 5, 2012 at 4:41 AM, aps [pushkardkumar@gmail.com](mailto:pushkardkumar@gmail.com) wrote:
> 
> > Hi,
> > 
> > We are indexing data which has various fields like Address, Phone  
> > Number,  
> > Street Number etc. The problem which we are facing is Address field has  
> > data  
> > space separated for .e.g "Oak Avenue", "Pretoria Avenue", "B Street", "A  
> > Street" etc.
> > 
> > When we search for Pretoria Avenue it gives all set of documents which  
> > has  
> > Pretoria as well as Avenue. But we need specific search to Pretoria  
> > Avenue  
> > only.
> > 
> > Same problem with Phone Number and Street Number it has data with "-",  
> > "."  
> > characters, and the document separate the data into 2 whenever it has  
> > "-" .
> > 
> > How and which analyzers we should use to get proper and specific results  
> > in  
> > that case?
> > 
> > Any help would be appreciated.
> > 
> > Thanks in advanced.

---

<div class="post-metadata">

**Author:** ![Shaun\_Farrell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaun_farrell/32/2827_2.png) [@Shaun\_Farrell](https://discuss.elastic.co/u/Shaun_Farrell)\
**Post date:** [July 5, 2012, 2:24pm UTC](https://discuss.elastic.co/t/need-help-to-apply-analyzers/8323/4 "2012-07-05T14:24:14Z")

</div>

I would also have a look at Multi-Fields… It stores data different ways. [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html)

--  
Shaun Farrell  
Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

On Thursday, July 5, 2012 at 9:52 AM, aps wrote:

> Thanks for the prompt response. Use of synonyms could be difficult because the data is huge and we cannot predict the data in advance.
> 
> We will look into custom analyzers for this, because we need documents to be searchable if I write only "pretoria".
> 
> On Thursday, 5 July 2012 14:27:28 UTC+2, Shaun Farrell wrote:
> 
> > In your mapping you can put
> > 
> > "index" : "not\_analyzed"
> > 
> > You can can also do this through your custom analyzer if you have one  
> > of those too.
> > 
> > Not Analyzed will not tokenize the string at all. The only issue I  
> > would see in your senerio is if i searched for "Oak Ave" that wouldn't  
> > come back. You might need to setup some synonyms or create a custom  
> > analyzer.
> > 
> > Shaun Farrell
> > 
> > On Thu, Jul 5, 2012 at 4:41 AM, aps \<[pushkardkumar@gmail.com](mailto:pushkardkumar@gmail.com) ([mailto:pushkardkumar@gmail.com](mailto:pushkardkumar@gmail.com))\> wrote:
> > 
> > > Hi,
> > > 
> > > We are indexing data which has various fields like Address, Phone Number,  
> > > Street Number etc. The problem which we are facing is Address field has data  
> > > space separated for .e.g "Oak Avenue", "Pretoria Avenue", "B Street", "A  
> > > Street" etc.
> > > 
> > > When we search for Pretoria Avenue it gives all set of documents which has  
> > > Pretoria as well as Avenue. But we need specific search to Pretoria Avenue  
> > > only.
> > > 
> > > Same problem with Phone Number and Street Number it has data with "-", "."  
> > > characters, and the document separate the data into 2 whenever it has "-" .
> > > 
> > > How and which analyzers we should use to get proper and specific results in  
> > > that case?
> > > 
> > > Any help would be appreciated.
> > > 
> > > Thanks in advanced.

---

<div class="post-metadata">

**Author:** ![aps](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@aps](https://discuss.elastic.co/u/aps)\
**Post date:** [July 9, 2012, 9:50am UTC](https://discuss.elastic.co/t/need-help-to-apply-analyzers/8323/5 "2012-07-09T09:50:04Z")

</div>

Hi Shaun,

The multi-field-type needs two searchable fields like in example one is  
Name and second one is untouched.name. This will be not suitable in our  
condition because we are searching based on one field.

Is there any other alternative which will satisfy our condition? I tried to  
make custom analyzer, what are the filters will make it not\_analyzed as  
well as searchable when give parts of the field string.

Thanks in advance.

On Thursday, 5 July 2012 16:24:14 UTC+2, Shaun Farrell wrote:

> I would also have a look at Multi-Fields… It stores data different ways.  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html)
> 
> --  
> Shaun Farrell  
> Sent with Sparrow [http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig)
> 
> On Thursday, July 5, 2012 at 9:52 AM, aps wrote:
> 
> Thanks for the prompt response. Use of synonyms could be difficult because  
> the data is huge and we cannot predict the data in advance.
> 
> We will look into custom analyzers for this, because we need documents to  
> be searchable if I write only "pretoria".
> 
> On Thursday, 5 July 2012 14:27:28 UTC+2, Shaun Farrell wrote:
> 
> In your mapping you can put
> 
> "index" : "not\_analyzed"
> 
> You can can also do this through your custom analyzer if you have one  
> of those too.
> 
> Not Analyzed will not tokenize the string at all. The only issue I  
> would see in your senerio is if i searched for "Oak Ave" that wouldn't  
> come back. You might need to setup some synonyms or create a custom  
> analyzer.
> 
> Shaun Farrell
> 
> On Thu, Jul 5, 2012 at 4:41 AM, aps [pushkardkumar@gmail.com](mailto:pushkardkumar@gmail.com) wrote:
> 
> > Hi,
> > 
> > We are indexing data which has various fields like Address, Phone  
> > Number,  
> > Street Number etc. The problem which we are facing is Address field has  
> > data  
> > space separated for .e.g "Oak Avenue", "Pretoria Avenue", "B Street", "A  
> > Street" etc.
> > 
> > When we search for Pretoria Avenue it gives all set of documents which  
> > has  
> > Pretoria as well as Avenue. But we need specific search to Pretoria  
> > Avenue  
> > only.
> > 
> > Same problem with Phone Number and Street Number it has data with "-",  
> > "."  
> > characters, and the document separate the data into 2 whenever it has  
> > "-" .
> > 
> > How and which analyzers we should use to get proper and specific results  
> > in  
> > that case?
> > 
> > Any help would be appreciated.
> > 
> > Thanks in advanced.

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [July 9, 2012, 8:15pm UTC](https://discuss.elastic.co/t/need-help-to-apply-analyzers/8323/6 "2012-07-09T20:15:10Z")

</div>

Assuming that you are using text queries[http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html),  
you might want to take a look at changing default operator from OR to AND  
or using text\_phrase queries.

On Monday, July 9, 2012 5:50:04 AM UTC-4, aps wrote:

> Hi Shaun,
> 
> The multi-field-type needs two searchable fields like in example one is  
> Name and second one is untouched.name. This will be not suitable in our  
> condition because we are searching based on one field.
> 
> Is there any other alternative which will satisfy our condition? I tried  
> to make custom analyzer, what are the filters will make it not\_analyzed as  
> well as searchable when give parts of the field string.
> 
> Thanks in advance.
> 
> On Thursday, 5 July 2012 16:24:14 UTC+2, Shaun Farrell wrote:
> 
> > I would also have a look at Multi-Fields… It stores data different ways.  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html)
> > 
> > --  
> > Shaun Farrell  
> > Sent with Sparrow [http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig)
> > 
> > On Thursday, July 5, 2012 at 9:52 AM, aps wrote:
> > 
> > Thanks for the prompt response. Use of synonyms could be difficult  
> > because the data is huge and we cannot predict the data in advance.
> > 
> > We will look into custom analyzers for this, because we need documents to  
> > be searchable if I write only "pretoria".
> > 
> > On Thursday, 5 July 2012 14:27:28 UTC+2, Shaun Farrell wrote:
> > 
> > In your mapping you can put
> > 
> > "index" : "not\_analyzed"
> > 
> > You can can also do this through your custom analyzer if you have one  
> > of those too.
> > 
> > Not Analyzed will not tokenize the string at all. The only issue I  
> > would see in your senerio is if i searched for "Oak Ave" that wouldn't  
> > come back. You might need to setup some synonyms or create a custom  
> > analyzer.
> > 
> > Shaun Farrell
> > 
> > On Thu, Jul 5, 2012 at 4:41 AM, aps [pushkardkumar@gmail.com](mailto:pushkardkumar@gmail.com) wrote:
> > 
> > > Hi,
> > > 
> > > We are indexing data which has various fields like Address, Phone  
> > > Number,  
> > > Street Number etc. The problem which we are facing is Address field has  
> > > data  
> > > space separated for .e.g "Oak Avenue", "Pretoria Avenue", "B Street",  
> > > "A  
> > > Street" etc.
> > > 
> > > When we search for Pretoria Avenue it gives all set of documents which  
> > > has  
> > > Pretoria as well as Avenue. But we need specific search to Pretoria  
> > > Avenue  
> > > only.
> > > 
> > > Same problem with Phone Number and Street Number it has data with "-",  
> > > "."  
> > > characters, and the document separate the data into 2 whenever it has  
> > > "-" .
> > > 
> > > How and which analyzers we should use to get proper and specific  
> > > results in  
> > > that case?
> > > 
> > > Any help would be appreciated.
> > > 
> > > Thanks in advanced.

---

<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, 3:20am UTC](https://discuss.elastic.co/t/need-help-to-apply-analyzers/8323/7 "2017-07-06T03:20:53Z")

</div>


