pelias / pelias/api

autocomplete: avoid trimming trailing spaces in sanitizer

Open
#1,544 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
259
Forks
168
Avg merge
6h 15m
Merged PRs (30d)
1

Description

for the autocomplete endpoint specifically, the presence of a trailing whitespace character in the input text has semantic value.

it indicates a word-boundary and that the final word which has been typed was completed and does not potentially represent a prefix.

looking at the sanitiser code, we trim whitespace from both sizes of the input before passing down to the tokenizer and parser functions which could use that information to make better decisions about what sort of queries to generate.

for example, the following queries should return different results, but currently return the same thing:

/v1/autocomplete?layers=country&text=uk

... should return

Ukraine
United Kingdom
/v1/autocomplete?layers=country&text=uk%20

... should *only* return

United Kingdom

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with sanitizer/_text.js, where the autocomplete input is trimmed before reaching the tokenizer and parser. Preserve the trailing whitespace signal for the autocomplete endpoint, then verify that inputs such as uk and uk%20 produce the distinct results described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, search
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.