2

firstly I'm new to Elasticsearch so I'm trying to figure out how to build an inteligent autocomplete. So my situation is like this:

  • I have a PostgreSql database which has some real estate offers registries,
  • I've built a service that update those registries with some geo information according to its location as jsonb column type;

So then I've read some Elasticsearch Completition suggestion's articles to understand how it works and I got the conclusion to index a document referenced to my pgdb offer's table, so I can create the document with parameters in a text format, e.g:

PG TABLE (offers)

    id |             address                   | parks_around
    1  |Avenida Diógenes Ribeiro de Lima, 2811 |      2
    2  |Avenida Paulista, 1044                 |      1
    2  |Avenida Ibirapuera, 2899               |      0

and then, When I sync my records to Elasticsearch I can index my doc like this:

    "mappings": {
        "offers": {
            "properties": {
                "external_id": {
                    "type": "integer"
                 },
                "address": {
                    "type": "text"
                 },
                "parks": {
                    "type": "text"
                 },
             }
        }
    }

then finally, index some docs with contextual phrases with bulk api:

    {index:{}}
    {
        "external_id": 1,
        "address": "Offer in Avenida Diógenes Ribeiro de Lima",
        "parks": "Offer with parks around"
    }  
    {index:{}}
    {
        "external_id": 2,
        "address": "Offer in Avenida Paulista",
        "parks": "Offer with park around"
    }
    {index:{}}
    {
        "external_id": 3,
        "address": "Offer in Avenida Ibirapuera",
        "parks": null
    }

My point is: Do I have to store my docs like an entire phrase to show completition higlighting suggestions as the user types?

Can anyone help me telling if it's far from the ideal solution?

Thanks in advance.

  • Your solution is not leveraging the `completion` field type, it seems, so you won't get autocomplete functionality like this. See this answer for more details: https://stackoverflow.com/questions/51085169/elastic-search-or-trie-for-search-autocomplete/51085473#51085473 – Val May 07 '19 at 03:58

0 Answers0