Can not have the same result

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.

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:

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

Or

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

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

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

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:

Look for comments.synonyms...

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.

1 Like

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