Dear team,
I'm trying to setup a query that contain a specific prefix in a provided text (not a keyword).
PUT my-index
{
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "standard",
"fields": {
"fr": {
"type": "text",
"analyzer": "french"
}
}
}
}
}
}
PUT my-index/_doc/1
{
"title": "L'Homme n'est rien d'autre que son projet."
}
GET my-index/_search
{
"query": {
"prefix": {
"title.fr": "hom"
}
}
}
This query must return the document with id: 1 (if the prefix query was analyzed).
As documented, prefix query is not analyzed, why such behavior?
At the moment, I'm creating a custom analyzer which inherits from language analyzer (same tokenizer, char_filter and filter) to which I add a edge_gram filter.
Then I can perform a match query with this custom analyzer. Moreover I can use multi_match query.
Is this solution correct? What do you advise me?
Best regards,
Davide MARTINS