Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create autocomplete endpoint #24

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andreformento
Copy link
Collaborator

@andreformento andreformento commented Apr 21, 2021

@jvanz @sergiomario

Prepare application

  • run application
  • add more cities for manual tests:
curl -X POST 'localhost:9200/gazettes/_doc?pretty' -H 'Content-Type: application/json' -d'{
  "source_text": "This is a fake gazette content",
  "power": "executive",
  "file_checksum": "2566f0e0ff98d899ee0633da64bc65e5",
  "file_path": "3304557/2019-02-26/c942328486185aa09ec19a7c723b3a33847258ee",
  "file_url": "https://doweb.rio.rj.gov.br/portal/edicoes/download/4067",
  "url": "https://doweb.rio.rj.gov.br/portal/edicoes/download/4067",
  "scraped_at": "2020-10-30T07:04:29.796347",
  "created_at": "2020-10-30T07:05:33.094289",
  "territory_id": "4202404",
  "territory_name": "Blumenau",
  "state_code": "SC",
  "edition_number": "123.45"
}'
curl -X POST 'localhost:9200/gazettes/_doc?pretty' -H 'Content-Type: application/json' -d'{
  "source_text": "tttt",
  "power": "executive",
  "file_checksum": "2566f0e0ff98d899ee0633da64bc65e5",
  "file_path": "3304557/2019-02-26/c942328486185aa09ec19a7c723b3a33847258ee",
  "file_url": "https://doweb.rio.rj.gov.br/portal/edicoes/download/4067",
  "url": "https://doweb.rio.rj.gov.br/portal/edicoes/download/4067",
  "scraped_at": "2020-10-30T07:04:29.796347",
  "created_at": "2020-10-30T07:05:33.094289",
  "territory_id": "4202404",
  "territory_name": "Blumenau",
  "state_code": "SC",
  "edition_number": "541"
}'
curl -X POST 'localhost:9200/gazettes/_doc?pretty' -H 'Content-Type: application/json' -d'{
  "source_text": "adasdsad",
  "power": "executive",
  "file_checksum": "2566f0e0ff98d899ee0633da64bc65e5",
  "file_path": "3304557/2019-02-26/c942328486185aa09ec19a7c723b3a33847258ee",
  "file_url": "https://doweb.rio.rj.gov.br/portal/edicoes/download/4067",
  "url": "https://doweb.rio.rj.gov.br/portal/edicoes/download/4067",
  "scraped_at": "2020-10-30T07:04:29.796347",
  "created_at": "2020-10-30T07:05:33.094289",
  "territory_id": "4302303",
  "territory_name": "Bom Jesus",
  "state_code": "RS",
  "edition_number": "541"
}'
curl -X POST 'localhost:9200/gazettes/_doc?pretty' -H 'Content-Type: application/json' -d'{
  "source_text": "aaaa",
  "power": "executive",
  "file_checksum": "2566f0e0ff98d899ee0633da64bc65e5",
  "file_path": "3304557/2019-02-26/c942328486185aa09ec19a7c723b3a33847258ee",
  "file_url": "https://doweb.rio.rj.gov.br/portal/edicoes/download/4067",
  "url": "https://doweb.rio.rj.gov.br/portal/edicoes/download/4067",
  "scraped_at": "2020-10-30T07:04:29.796347",
  "created_at": "2020-10-30T07:05:33.094289",
  "territory_id": "4302303",
  "territory_name": "Bom Jesus",
  "state_code": "RS",
  "edition_number": "541"
}'
curl -X POST 'localhost:9200/gazettes/_doc?pretty' -H 'Content-Type: application/json' -d'{
  "source_text": "PB 1",
  "power": "executive",
  "file_checksum": "2566f0e0ff98d899ee0633da64bc65e5",
  "file_path": "3304557/2019-02-26/c942328486185aa09ec19a7c723b3a33847258ee",
  "file_url": "https://doweb.rio.rj.gov.br/portal/edicoes/download/4067",
  "url": "https://doweb.rio.rj.gov.br/portal/edicoes/download/4067",
  "scraped_at": "2020-10-30T07:04:29.796347",
  "created_at": "2020-10-30T07:05:33.094289",
  "territory_id": "2502201",
  "territory_name": "Bom Jesus",
  "state_code": "PB",
  "edition_number": "541"
}'
curl -X POST 'localhost:9200/gazettes/_doc?pretty' -H 'Content-Type: application/json' -d'{
  "source_text": "PB 2",
  "power": "executive",
  "file_checksum": "2566f0e0ff98d899ee0633da64bc65e5",
  "file_path": "3304557/2019-02-26/c942328486185aa09ec19a7c723b3a33847258ee",
  "file_url": "https://doweb.rio.rj.gov.br/portal/edicoes/download/4067",
  "url": "https://doweb.rio.rj.gov.br/portal/edicoes/download/4067",
  "scraped_at": "2020-10-30T07:04:29.796347",
  "created_at": "2020-10-30T07:05:33.094289",
  "territory_id": "2502201",
  "territory_name": "Bom Jesus",
  "state_code": "PB",
  "edition_number": "541"
}'

tests

{
    "suggestions": [
        {
            "state_code": "PB",
            "territory_id": "2502201",
            "territory_name": "Bom Jesus"
        },
        {
            "state_code": "SC",
            "territory_id": "4202404",
            "territory_name": "Blumenau"
        },
        {
            "state_code": "RS",
            "territory_id": "4302303",
            "territory_name": "Bom Jesus"
        }
    ]
}
{
    "suggestions": [
        {
            "state_code": "SC",
            "territory_id": "4202404",
            "territory_name": "Blumenau"
        }
    ]
}
  • call autocomplete with bo
  • should return 2 different cities
{
    "suggestions": [
        {
            "state_code": "PB",
            "territory_id": "2502201",
            "territory_name": "Bom Jesus"
        },
        {
            "state_code": "RS",
            "territory_id": "4302303",
            "territory_name": "Bom Jesus"
        }
    ]
}
  • call autocomplete with b with size=2
  • should return 2 different cities
{
    "suggestions": [
        {
            "state_code": "PB",
            "territory_id": "2502201",
            "territory_name": "Bom Jesus"
        },
        {
            "state_code": "SC",
            "territory_id": "4202404",
            "territory_name": "Blumenau"
        }
    ]
}

Copy link
Collaborator

@jvanz jvanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed in a previous call. We are not sure if the territory name will come from ElasticSearch index. So, for now, let keep this open until we define this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants