# Can not have the same result

**URL:** <https://discuss.elastic.co/t/can-not-have-the-same-result/336460>\
**Category:** Elasticsearch\
**Created:** [June 20, 2023, 9:32am UTC](https://discuss.elastic.co/t/can-not-have-the-same-result/336460 "2023-06-20T09:32:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephane\_chan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephane_chan/32/122193_2.png) [@stephane\_chan](https://discuss.elastic.co/u/stephane_chan)\
**Post date:** [June 20, 2023, 9:32am UTC](https://discuss.elastic.co/t/can-not-have-the-same-result/336460/1 "2023-06-20T09:32:51Z")

</div>

Hi,

I can't do a song search on an elasticsearch lyrics excerpt,  
The lyric:  
"... Na dia mbola zaza Na dia mbola kely ..."  
if I search for "mbola zaza" it gives me the result but if I type "ola zaza" it gives me no result. Why ?  
I use the standard analyzer.

Similarly, if I type "name\_song artist\_song" / "artist\_song name\_song" it doesn't give me any results.  
but if I type "name\_song" or "artist\_song" it gives me results.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 20, 2023, 10:06am UTC](https://discuss.elastic.co/t/can-not-have-the-same-result/336460/2 "2023-06-20T10:06:04Z")

</div>

Bonjour Stéphane

It's because the standard analyzer is analyzing your text `Na dia mbola zaza Na dia mbola kely` as [`na`, `dia`, `mbola`, `zaza`, `na`, `dia`, `mbola`, `kely`]

When you search for `ola`, it can not find `mbola` because it's not the same token.

You need to change the analyzer to support partial search and use ngram based analyzers.

For example, you can try this:

```auto
POST _analyze
{
  "tokenizer": "standard", 
  "filter": [ 
    {"type": "ngram", "min_gram" : 2, "max_gram" : 3}
  ],
  "text": ["mbola"]
}

```

Or

```auto
POST _analyze
{
  "tokenizer": "standard", 
  "filter": [ 
    {"type": "edge_ngram", "min_gram" : 2, "max_gram" : 5}
  ],
  "text": ["mbola"]
}

```

---

<div class="post-metadata">

**Author:** ![stephane\_chan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephane_chan/32/122193_2.png) [@stephane\_chan](https://discuss.elastic.co/u/stephane_chan)\
**Post date:** [June 20, 2023, 11:31am UTC](https://discuss.elastic.co/t/can-not-have-the-same-result/336460/3 "2023-06-20T11:31:31Z")

</div>

Hi @dadoonet,

That makes more sense. So what you're suggesting is that I create my own analyzer? And my question is, can we put several analyzers on one field in the mappings?  
I'm new in elasticsearch , and I don't know much about analyzer, so if you can give me some guidance  
there's also the search for "artist\_name song\_name" or "song\_name artist\_name" which also remains to be resolved

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 20, 2023, 11:54am UTC](https://discuss.elastic.co/t/can-not-have-the-same-result/336460/4 "2023-06-20T11:54:33Z")

</div>

> [@stephane\_chan](#):
>
> So what you're suggesting is that I create my own analyzer?

Yes. If the provided ones don't match your use case, bring your own analyzer.

> [@stephane\_chan](#):
>
> can we put several analyzers on one field in the mappings?

Yes and no. Actually no. But you can define a subfield like `foo.ngram` which will use the same text content provided in the `foo` field and apply another analyzer.

There's an example of that at:

> <https://gist.github.com/dadoonet/5179ee72ecbf08f12f53d4bda1b76bab>

Look for `comments.synonyms`...

> [@stephane\_chan](#):
>
> there's also the search for "artist\_name song\_name" or "song\_name artist\_name" which also remains to be resolved

If you search using a multimatch query on both fields, I believe this will work out of the box... Have a llok at the example I just shared. That might guide you.

---

<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 18, 2023, 11:54am UTC](https://discuss.elastic.co/t/can-not-have-the-same-result/336460/5 "2023-07-18T11:54:57Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
