Help for configuring index and query for autocomplete full_text_search on addresses

Hello,

I am creating an index to search existing addresses.

Unfortunately I don't have some good results at all and I would like to ask for advices on how to improove these results.

So the aim is to let a user enter in a single input a text that could be "zeedijk, 351 Koksijde" for example. And we would like to match the most precise address that corresponds to this text according to multiple fields. Unfortunately, the clients are lazy and would like for example to find the addresses that contains (in city or street for example) "Luxembourg" when typing "lux".
They also would like the query to function even if there is some special characters like é: "rue d'herinne" should return the street named "rue d'hérinnes".

Right now the index is created

{
  "mappings": {
    "properties": {
      "boite": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "codePostal": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "codepostal": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "id": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "localite": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "municipalite": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "numero": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "region": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "rue": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      }
    }
  }
}

I tried executing queries against it wiht the _search endpoint:

{
  "query": {
    "multi_match": {
      "query": "Koksijde",
      "fields": ["rue^5", "municipalite^5",  "localite^2", "codePostal^5", "numero"],
      "boost": 5,
      "fuzziness": "AUTO",
      "type": "most_fields"
    }
  }
}

it works quite well BUT in the exact query above there is a major problem: the addresses with the exact word "Koksijde" are not the firsts results. Instead I have

{
          "rue": "Nieuwe Kalsijde",
          "municipalite": "Langemark-Poelkapelle",
          "numero": "17",
          "id": "1a891ec7-f828-42ec-b8ab-c7a109ac7a27-nl",
          "codePostal": "8920"
        }

And i don't understand how to adress (pun intended) the problem.
The problem comes from the fuzziness but if I remove it, there is no "autocompletion" or "fault-tolerance" mechanism...

Could you please help me?
It would be much appreciated.

Welcome!

I ran a talk several times about this.

Mapping is important:

Note the asciifolding, elision and synonyms...
And also this line is super important:

If you are speaking french, you could watch the video on this page: Enrichir ses adresses postales avec la suite Elastic

Or this one (older) in english: Enriching postal addresses with Elastic stack

Hope this could help.

1 Like

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