0

I'm using Search API and Search Views to search the Drupal user database.

One of the fields is phone number where users are able to enter free text.

I can include this field in the search, but the search will not pick up part words.

E.g. 6162 5555 - does not display when I search for 25555 because the index sees these terms as separate words.

Is there a way to strip all the site space (and maybe then brackets) from the field before it is indexed by Search API?

  • Is this any real need to store that spaces? – Mołot Jun 18 '13 at 6:52
  • Yes. Maybe the user wants to just enter an extension, or maybe a mobile number or maybe a regular 8 digit number, in which case its up the user where they want the spaces. – user5681 Jun 18 '13 at 6:57
1

I would use Computed Fields. Store and display user input with spaces, but index and search computed field too.

These computed fields are populated with values that you define via PHP code.

So you can simply remove white spaces, or re-format phone number in any way you please, and store a standardised copy of user's phone number. That way both representations will be searchable.

As a small bonus, other modules (like Views, various exporters and connectors or phone integration) would be able to benefit from this too. Bad thing is a slight overhead on reads and saves.

0

enter image description here

You need to disable Tokenizer. Then it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy