# What is required for partial match to work?

**URL:** <https://discuss.elastic.co/t/what-is-required-for-partial-match-to-work/4764>\
**Category:** Elasticsearch\
**Created:** [July 4, 2011, 7:54am UTC](https://discuss.elastic.co/t/what-is-required-for-partial-match-to-work/4764 "2011-07-04T07:54:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raul\_Jr\_Martinez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raul_jr_martinez/32/1286_2.png) [@Raul\_Jr\_Martinez](https://discuss.elastic.co/u/Raul_Jr_Martinez)\
**Post date:** [July 4, 2011, 7:54am UTC](https://discuss.elastic.co/t/what-is-required-for-partial-match-to-work/4764/1 "2011-07-04T07:54:30Z")

</div>

Hello,

I'm pretty much new to ElasticSearch and my question is on partial  
match and is somehow related to an older post and figured out that the  
old thread didn't contain answers I was looking for:  
[http://groups.google.com/a/elasticsearch.com/group/users/browse\_thread/thread/57f551b0897bf55c/be5276d04f0ba1f5?lnk=gst&q=Partial+Search#be5276d04f0ba1f5](http://groups.google.com/a/elasticsearch.com/group/users/browse_thread/thread/57f551b0897bf55c/be5276d04f0ba1f5?lnk=gst&q=Partial+Search#be5276d04f0ba1f5)

Anyway, I have one document with title containing the word  
"ULTRALIGHT". I want to make sure that when I search for "ULTRA" or  
"LIGHT", the said document should be included in the result set.

I am using query\_string when searching. How do I go about making sure  
that I get this result? Should I be using Fuzzy or FLT?

Thanks,

Raul

---

<div class="post-metadata">

**Author:** ![Paul\_Loy](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@Paul\_Loy](https://discuss.elastic.co/u/Paul_Loy)\
**Post date:** [July 4, 2011, 10:02am UTC](https://discuss.elastic.co/t/what-is-required-for-partial-match-to-work/4764/2 "2011-07-04T10:02:14Z")

</div>

Depends on what your data is going to be like. Are these real words, or  
usernames?

You can use n-gram, but be careful as depending on your values for n you can  
get lots of matches that may seem unrelated. I use n-gram for usernames.

On Mon, Jul 4, 2011 at 8:54 AM, rmartinez [juneym@gmail.com](mailto:juneym@gmail.com) wrote:

> Hello,
> 
> I'm pretty much new to Elasticsearch and my question is on partial  
> match and is somehow related to an older post and figured out that the  
> old thread didn't contain answers I was looking for:
> 
> [http://groups.google.com/a/elasticsearch.com/group/users/browse\_thread/thread/57f551b0897bf55c/be5276d04f0ba1f5?lnk=gst&q=Partial+Search#be5276d04f0ba1f5](http://groups.google.com/a/elasticsearch.com/group/users/browse_thread/thread/57f551b0897bf55c/be5276d04f0ba1f5?lnk=gst&q=Partial+Search#be5276d04f0ba1f5)
> 
> Anyway, I have one document with title containing the word  
> "ULTRALIGHT". I want to make sure that when I search for "ULTRA" or  
> "LIGHT", the said document should be included in the result set.
> 
> I am using query\_string when searching. How do I go about making sure  
> that I get this result? Should I be using Fuzzy or FLT?
> 
> Thanks,
> 
> Raul

## --

Paul Loy  
[paul@keteracel.com](mailto:paul@keteracel.com)  
[http://uk.linkedin.com/in/paulloy](http://uk.linkedin.com/in/paulloy)

---

<div class="post-metadata">

**Author:** ![Raul\_Jr\_Martinez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raul_jr_martinez/32/1286_2.png) [@Raul\_Jr\_Martinez](https://discuss.elastic.co/u/Raul_Jr_Martinez)\
**Post date:** [July 5, 2011, 3:32pm UTC](https://discuss.elastic.co/t/what-is-required-for-partial-match-to-work/4764/3 "2011-07-05T15:32:14Z")

</div>

Hi Paul,

The is in the form of Articles and free-form text like classified ads.

I will try N-gram and see if it works for me. By the way, I used FLT  
but it seems that I need to actually investigate why some "unrelated"  
documents are matching... maybe it's too fuzzy 🙂

Regards,  
Raul

On Jul 4, 6:02 pm, Paul Loy [ketera...@gmail.com](mailto:ketera...@gmail.com) wrote:

> Depends on what your data is going to be like. Are these real words, or  
> usernames?
> 
> You can use n-gram, but be careful as depending on your values for n you can  
> get lots of matches that may seem unrelated. I use n-gram for usernames.
> 
> On Mon, Jul 4, 2011 at 8:54 AM, rmartinez [jun...@gmail.com](mailto:jun...@gmail.com) wrote:
> 
> > Hello,
> 
> > I'm pretty much new to Elasticsearch and my question is on partial  
> > match and is somehow related to an older post and figured out that the  
> > old thread didn't contain answers I was looking for:
> 
> > [http://groups.google.com/a/elasticsearch.com/group/users/browse\_threa](http://groups.google.com/a/elasticsearch.com/group/users/browse_threa)...
> 
> > Anyway, I have one document with title containing the word  
> > "ULTRALIGHT". I want to make sure that when I search for "ULTRA" or  
> > "LIGHT", the said document should be included in the result set.
> 
> > I am using query\_string when searching. How do I go about making sure  
> > that I get this result? Should I be using Fuzzy or FLT?
> 
> > Thanks,
> 
> > Raul
> 
> ## --
> 
> Paul Loy  
> p...@keteracel.comhttp://uk.linkedin.com/in/paulloy

---

<div class="post-metadata">

**Author:** ![Paul\_Loy](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@Paul\_Loy](https://discuss.elastic.co/u/Paul_Loy)\
**Post date:** [July 6, 2011, 9:31am UTC](https://discuss.elastic.co/t/what-is-required-for-partial-match-to-work/4764/4 "2011-07-06T09:31:06Z")

</div>

N-gram will probably be worse for matching unrelated docs...

On Tue, Jul 5, 2011 at 4:32 PM, rmartinez [juneym@gmail.com](mailto:juneym@gmail.com) wrote:

> Hi Paul,
> 
> The is in the form of Articles and free-form text like classified ads.
> 
> I will try N-gram and see if it works for me. By the way, I used FLT  
> but it seems that I need to actually investigate why some "unrelated"  
> documents are matching... maybe it's too fuzzy 🙂
> 
> Regards,  
> Raul
> 
> On Jul 4, 6:02 pm, Paul Loy [ketera...@gmail.com](mailto:ketera...@gmail.com) wrote:
> 
> > Depends on what your data is going to be like. Are these real words, or  
> > usernames?
> > 
> > You can use n-gram, but be careful as depending on your values for n you  
> > can  
> > get lots of matches that may seem unrelated. I use n-gram for usernames.
> > 
> > On Mon, Jul 4, 2011 at 8:54 AM, rmartinez [jun...@gmail.com](mailto:jun...@gmail.com) wrote:
> > 
> > > Hello,
> > 
> > > I'm pretty much new to Elasticsearch and my question is on partial  
> > > match and is somehow related to an older post and figured out that the  
> > > old thread didn't contain answers I was looking for:
> > 
> > > [http://groups.google.com/a/elasticsearch.com/group/users/browse\_threa](http://groups.google.com/a/elasticsearch.com/group/users/browse_threa).  
> > > ..
> > 
> > > Anyway, I have one document with title containing the word  
> > > "ULTRALIGHT". I want to make sure that when I search for "ULTRA" or  
> > > "LIGHT", the said document should be included in the result set.
> > 
> > > I am using query\_string when searching. How do I go about making sure  
> > > that I get this result? Should I be using Fuzzy or FLT?
> > 
> > > Thanks,
> > 
> > > Raul
> > 
> > ## --
> > 
> > Paul Loy  
> > p...@keteracel.comhttp://uk.linkedin.com/in/paulloy

## --

Paul Loy  
[paul@keteracel.com](mailto:paul@keteracel.com)  
[http://uk.linkedin.com/in/paulloy](http://uk.linkedin.com/in/paulloy)

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [July 6, 2011, 9:51am UTC](https://discuss.elastic.co/t/what-is-required-for-partial-match-to-work/4764/5 "2011-07-06T09:51:01Z")

</div>

On Wed, 2011-07-06 at 10:31 +0100, Paul Loy wrote:

> N-gram will probably be worse for matching unrelated docs...

Ngrams should usually only be used in the index\_analyzer, not the  
search\_analyzer, to improve result relevancy.

For instance:

We index the text "apple" with an edge ngram analyzer, and get:

- a,ap,app,appl,apple

When we analyze the search text, we can do it with ngrams or without  
ngrams. This is what you would see:

The user wants to search for "application", and starts typing:

```
           no-ngram ngram
--------------------------------------------
a match match
ap match match
app match match
appl match match
appli no match match*
applic no match match*

```

Those last two results show why you usually don't want to use the ngram  
version at search time.

To achieve this, when you specify the mapping for a field, you can do:

{ my\_content: {  
type: "string",  
index\_analyzer: "my\_ngram\_analyzer",  
search\_analyzer: "default"  
}}

clint

---

<div class="post-metadata">

**Author:** ![Raul\_Jr\_Martinez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raul_jr_martinez/32/1286_2.png) [@Raul\_Jr\_Martinez](https://discuss.elastic.co/u/Raul_Jr_Martinez)\
**Post date:** [July 8, 2011, 12:32am UTC](https://discuss.elastic.co/t/what-is-required-for-partial-match-to-work/4764/6 "2011-07-08T00:32:31Z")

</div>

THis works for me.

> <https://gist.github.com/juneym/1070860>

{ content: {  
type: "string",  
index\_analyzer: "ascAnalyzer1",  
search\_analyzer: "default"  
}}

On Jul 6, 5:51 pm, Clinton Gormley [clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) wrote:

> On Wed, 2011-07-06 at 10:31 +0100, Paul Loy wrote:
> 
> > N-gram will probably be worse for matching unrelated docs...
> 
> Ngrams should usually only be used in the index\_analyzer, not the  
> search\_analyzer, to improve result relevancy.
> 
> For instance:
> 
> We index the text "apple" with an edge ngram analyzer, and get:
> 
> - a,ap,app,appl,apple
> 
> When we analyze the search text, we can do it with ngrams or without  
> ngrams. This is what you would see:
> 
> The user wants to search for "application", and starts typing:
> 
> ```
> no-ngram ngram
> --------------------------------------------
> a match match
> ap match match
> app match match
> appl match match
> appli no match match*
> applic no match match*
> 
> ```
> 
> Those last two results show why you usually don't want to use the ngram  
> version at search time.
> 
> To achieve this, when you specify the mapping for a field, you can do:
> 
> { my\_content: {  
> type: "string",  
> index\_analyzer: "my\_ngram\_analyzer",  
> search\_analyzer: "default"  
> }}
> 
> clint

---

<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, 4:01am UTC](https://discuss.elastic.co/t/what-is-required-for-partial-match-to-work/4764/7 "2017-07-06T04:01:22Z")

</div>


