2

The Addressfield module stores an abbrivated name for countries and state such as US for United States and FL for Florida. The Search API indexes the these words which are not very useful when doing searches for places like New York, Boston, France, ect.. Should I just discard the Addressfield module and make text fields or is there another way to go about doing this?

1
  • Are you asking about addressfield module?
    – googletorp
    Sep 5 '11 at 6:11
1

you might want to use SOLR search and write a synonym.txt file to translate the state and country codes into names

3
  • 1
    I'm using Searh API and it turns out that it provides a hook, hook_search_api_index_items_alter(), that enables a developer to alter each item before it is index in Solr. So, in this case for each country I can map the abbreviation state name to a full name.
    – Adam S
    Oct 5 '11 at 17:54
  • great find. Would you mind sharing the code when it's done. Hope you don't have to hard code the country/state values. Not sure where addressfield stores those values. I couldn't find a table in my drupal DB.
    – uwe
    Oct 5 '11 at 19:29
  • @AdamS S, Have share the code somewhere ? I have the same problem that you are having but I cant modify the synonym.txt because I'm hosting with Pantheon and they dont allow you to modify the synonym.txt. I notice that you open an issue drupal.org/node/1269608 however, there is not a patch available yet. Feb 19 '15 at 18:42
1

I have created a sandbox module called Search API Addressfield Country Name which handles the conversion of 2-letter country codes to country names.

For expanding state names, check out the issue on Drupal.org Integrate Addressfield with Search API

2
  • Does the patch in the second link fully integrates searchapi with addressfield? I mean will it allow country as well as state and city search?
    – Umair
    Jan 22 '18 at 15:41
  • I didn't write any of the patches in the 2nd link, so I cannot be sure. But the patch from #34 only shows the State expanded, i.e. "CA" => "CA California". You can comment on that thread if you need further clarification.
    – hargobind
    Apr 29 '18 at 18:47
0

Unless somebody is going to write a rather sophisticated plugin or module to do this as contrib to either the Addressfield module or Search API I doubt this will ever work. The Addressfield module is extremely complex not opening itself to easy integration. Sadly, the best solution is the simplest which is to create text fields. The Geocode module still geocodes the addresses which can be used by the Apache Solr Seach API which is nice.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.