Search API Autocomplete does not find CEP (zipcode in Brazil) or number that starts with 0 (zero). Eg: When I type: 08090, no suggestion appears. If I digital 8090, it suggested 8090710 in the autocomplete field. But the number registered on the node is 08090710.

I need it to locate with 0 (zero) at the beginning.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wesleybpereira created an issue. See original summary.

wesleybpereira’s picture

Assigned: wesleybpereira » Unassigned
drunken monkey’s picture

Project: Search API Autocomplete » Search API Database Search
Version: 7.x-1.4 » 7.x-1.x-dev
Priority: Major » Normal
Status: Active » Needs review
FileSize
1.17 KB

Apparently you're using the Database backend for your search server?
In that case, this is a known problem: to facilitate reliable searches for numbers, we index them in a canonical form, without sign or leading zeroes. Since autocomplete can only use the data in the index to create its suggestions, it can't know that that number originally had a leading zero, and creates the suggestion just for the bare number.

However, if we have hard-coded token preprocessing at indexing (and search) time, we should also do the same when creating autocomplete suggestions. The attached patch should at least alleviate the problem – please try it out!

drunken monkey’s picture

Re-attaching to trigger test bot.

wesleybpereira’s picture

It worked! Thank you so much.

  • drunken monkey committed 13a683d on 7.x-1.x
    Issue #2879881 by drunken monkey: Fixed preprocessing of autocomplete...
drunken monkey’s picture

Component: Miscellaneous » Code
Status: Needs review » Fixed

Good to hear, thanks for testing and reporting back!
Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.