Google Places API gives name of the state as city in the suggestion - web-services

We are using google places API to autocomplete state, city or region searches. The issue is when one searches for a state, Places API gives two results one for the state and the other for the city/region. For eg, if we search Maine we get Maine, USA and Maine, ME, USA both in the response. Would anyone please provide a way to avoid this duplication?

Do you use "types" parameter?
https://developers.google.com/maps/documentation/places/web-service/autocomplete#types
"cities" type might give the result you want.

Related

Hapi FHIR: searching for patient identifier using Postman

I am using Postman to test the connectivity with the Hapi FHIR server and have have been testing different queries but nothing is working...
The expected result is to get all the observations that match a certain patient identifier but, at this point, I could only get information by searching for the patient ID.
This is the base query:
http://hapi.fhir.org/baseR4/Observation
I tried lots of different parameters, including:
?identifier:of-type={identifier.system OR identifier.type.coding.system}|MR|1234
?patient.identifier=1234 OR {full url from above}
?identifier={full url OR 1234}
?subject=1234
?_has:Observation:patient:identifier=1234
and so many others. They either respond with a 500, 400 or a 200OK but with nothing in the Bundle. I checked if I had the patient itself as well as the observations and they are all there, if I search using their ID.
If you have an Observation that is correctly linked to a Patient, you can search for the Observations using the Patient's identifier.
My comment was to try and check if the Observation(s) is/are correctly linked to the Patient. So if you have a Patient with technical id 234567 and identifier 1234, does the Observation.subject field show [base]/Patient/234567? If so, this search will work on HAPI:
GET [base]/Observation?patient.identifier=1234
Also, these searches will work, but they use the technical id instead of the identifier:
GET [base]/Observation?patient=234567
GET [base]/Observation?subject=Patient/234567

openstreetmap response - importance and place_rank fields

What is the meaning of the 'importance' and 'place_rank' fields in a openstreetmap response ? I can't find it anywhere in the documentation :/
For example the response of this url:
http://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon=1&addressdetails=1
is:
<place place_id="62311100" osm_type="way" osm_id="90394480" place_rank="30" ...OMISSIS... importance="0.701">
In the above response I have removed all the XML part I'm not interested in.
As far as I know:
The importance is used for ordering search results according to their relevance. The importance value is calculated/estimated using various attributes including the place's popularity on Wikipedia and its rank.
The rank is based on a rather complex algorithm taking the place type and various other attributes into account. For example it seems checks whether this object is a village, a city, a country, a continent, a highway, a lake and similar other properties.
Unfortunately these attributes lack proper documentation. So all you can do is try to look at Nominatim's source code if you need more detailed information. From there I tried to extract the information mentioned above.

SOLR query exclusions

I'm having an issue with querying an index where a common search term also happens to be part of a company name interspersed throughout most of the documents. How do I exclude the business name in results without effecting the ranking on a search that includes part of the business name?
example: Bobs Automotive Supply is the business name.
How can I include relevant results when someone searches automotive or supply without returning every document in the index?
I tried "-'Bobs Automotive Supply' +'search term'" but this seems to exclude any document with Bobs Automotive Supply and isn't very effective on searching 'supply' or 'automotive'
Thanks in advance.
Second answer here, based on additional clarification from first answer.
A few options.
Add the business name as StopWords in the StopWordFilter. This will stop Solr from Indexing them at all. Searches that use them will only really search for those words that aren't in the business name.
Rely on the inherent scoring that Solr will apply due to Term frequency. It sounds like these terms will be in the index frequently. Queries for them will still return the documents, but if the user queries for other, less common terms, those will get a higher score.
Apply a low query boost (not quite negative, but less than other documents) to documents that contain the business name. This is covered in the Solr Relevancy FAQ http://wiki.apache.org/solr/SolrRelevancyFAQ#How_do_I_give_a_negative_.28or_very_low.29_boost_to_documents_that_match_a_query.3F
Do you know that the article is tied to the business name or derive this? If so, you could create another field and then just exclude entities that match on the business name using a filter query. Something like
q=search_term&fq=business_name:(NOT search_term)
It may be helpful to use subqueries for this or to just boost down rather than filter out results.
EDIT: Update to question make this irrelavent. Leaving it hear for posterity. :)
This is why Solr Documents have different fields.
In this case, it sounds like there is a "Footer" field that is separate from your "Body" field in your documents. When searches are performed, they would only done against the Body, which won't include data from the Footer. You could even have a third field which is the "OriginalContent" field, which contains the original copy for display purposes. You wouldn't search that, just store it for later.
The important part is to create the two separate fields in your schema and make sure that you index those field that you want to be able to search.

Order totals block on Magento order email and invoice email templates

Can anyone point me to the templates/code blocks that are used for the order totals block on the Magento order mail and invoice e-mail templates?
The tax issue is solved but I need to implement some logic to get rid of the shipping and the subtotal. Which templates are used for the emails?
I found the frontend and changed this as needed, but can't find the template/block that is used for the e-mails sent by the system.
Can anyone point me in the right direction?
Thanks,
Bart
Niels answer of app/design/frontend/base/default/template/sales/order/totals.phtml is correct however I thought some further clarification was in order because one doesn't merely make cosmetic changes to this file in order to effect the desired change. totals.phtml loops over the "totals", each of which produces a total-related line-item (Subtotal, Shipping & Handling, Tax, Grand Total (Excl. Tax), and Grand Total (Incl. Tax)). Your best bet is to use Mage::Log to output each of the totals (which are looped over via an associative array $_code => $total). If you log each key ($_code), you'll see names such as subtotal, shipping, grand_total, tax, and grand_total_incl. I filtered out those from the sales order e-mail that I didn't want by adding the following code directly below the foreach:
<?php if (in_array($_code, array('grand_total'))) {
continue;
} ?>
Hopefully this will help anybody who is puzzling over where these totals are mysteriously coming from. :-)
This template is being used for the totals in the e-mail templates and order overview in My Account:
app/design/frontend/base/default/template/sales/order/totals.phtml
Jason's answer is good for telling Magento to not generate the likes of grand_total HTML. However, you should look at System > Configuration > Sales > Tax to see if you can remove the fields the proper way first.
If you then see a message saying "Warning tax configuration can result in rounding errors" at the top of your admin pages, you'll need to adjust your settings. See the manual for the default settings, if you need them.
I am not entirely sure but could it be this one:
\app\design\adminhtml\default\default\template\email\order\items.phtml
Directory might not exactly match yours but I'm sure you would be able to find it.
HTH

Using Geo APIs to pick a random town from anywhere in the world

I'm trying to use Yahoo's excellent GeoPlanet API:
http://developer.yahoo.com/geo/geoplanet/guide/api-reference.html
I would like to pick a random town from anywhere in the world but can't see an easy way to do it. I have tried querying by country and asking for children of type 'town', but can't seem to do that directly.
Can anyone think of a way to pluck out a random town WOEID without having to query the country, then the admin regions, then the admin 2, then the admin 3 etc.
I have also experimented using YQL, but don't have enough of an understanding about the available APIs.
Have a look at http://world-gazetteer.com/.
You can store all towns in your local database, then do random select, and then just geocode selected town using any geocode service you like.
Just for phun, why not generate random lat/long & display whatever is there?