<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "How to build a "Suggest" search"]]></title>
		<link>http://forum.geonames.org/gforum/posts/list/4.page</link>
		<description><![CDATA[Latest messages posted in the topic "How to build a "Suggest" search"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>How to build a "Suggest" search</title>
				<description><![CDATA[ Hi everyone!

I plan to build an AJAX "Suggest" search (just like <a href="http://www.google.com/webhp?complete=1&hl=en" target="_new" rel="nofollow">Google Suggest</a>) for populated place names. In my search box a search for "b" should bring
1) countries that start with "b"
2) capitals with "b"
3) big cities with "b"
4) any other places with "b"
Problem: the user would always see only the top 10 results of his search!

<b>Speed:</b> How would you do the technical part? I read somewhere that one could use <a href="http://www.sphinxsearch.com/" target="_new" rel="nofollow">Sphinx</a> to speed up the process and to use a secondary column "suggest matches", that would e.g. for "Bangkok" contain "B Ba Ban Bang ...". What do you think of that approach?

<b>What to include:</b> Are there any feature classes that you would spare? For example H, L, R and U seem to be of less importance considering above search?
And how would you treat the alternative names, given that there is not always a translation for a specific language (e.g. 'de') but you still need a result?

<b>ORDER BY ...:</b> What sort criteria would you use in order to make the result list as intuitive as possible? Probably first order by "A PCL", "A ...", "P PPLC", "P ..." and then order by population?
But I am not sure how to do this in MySQL, since the order is not alphabetical. Is there a way to tell MySQL the desired order of feature classes? Or will I need several queries?

Sorry for all these questions, but probably at the end this will help others too!
Eddie]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/list/748.page#3382</guid>
				<link>http://forum.geonames.org/gforum/posts/list/748.page#3382</link>
				<pubDate><![CDATA[Mon, 21 Jan 2008 00:58:44]]> GMT</pubDate>
				<author><![CDATA[ Eddie]]></author>
			</item>
			<item>
				<title>How to build a "Suggest" search</title>
				<description><![CDATA[ Re the note on using Sphinx, it was probably my misinformation, but you dont actully need to create that column, Sphinx can do it transarently at the indexing stage. 

what to include... I wondered this, in the end not sure can leave anything out, you just want them very low priority so they come last :)

order by ... I've done basically that in a prototype I am building, but didnt think about the population (although now think it I think geonames does that!) ... what I did was assigna  sort order (manually) to each feature code, and sort on that. (can either add it as another column, or just join with a table of feature codes) ]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/list/748.page#3391</guid>
				<link>http://forum.geonames.org/gforum/posts/list/748.page#3391</link>
				<pubDate><![CDATA[Mon, 21 Jan 2008 22:25:39]]> GMT</pubDate>
				<author><![CDATA[ barryhunter]]></author>
			</item>
			<item>
				<title>Re:How to build a "Suggest" search</title>
				<description><![CDATA[ You may have moved on to other things by now, but I wanted to provide a similar capability in my Books / Maps mashup, <a href='www.codexmap.com' target='_new' rel="nofollow">www.codexmap.com</a>. I use scriptaculous for Ajaxy stuff, in particular for this I used the Autocompleter, a nifty component that provides a lookahead/suggest framework. You can read many tutorials on the web or on the Scriptaculous site for how to use it. In my case, I include the attached HTML fragment in my page, and it references a PHP script (also attached) which generates the suggest candidates by calling the Geonames web service. 

Basically it just calls the geonames web service with the search string the user has typed so far, and leaves the sorting of the candidates to Geonames -  it does a reasonable job of this, and you may find it hard to do a better job than the author of Geonames has already done. 

My script is pre-configured to only generate 10 suggestions, but it's easy to alter that variable to include more if you have screenspace for them. The more you type, the more likely the suggest will capture what you want. Also, I included some of the features codes in the lookahead string so you might see more detail on what the suggested candidates are. I've also attached a screenshot. You can see this in action on any book page in CodexMap, for example The DaVinci Code page in the image is at: <a href='http://codexmap.com/book.php?bookid=2848' target='_new' rel="nofollow">http://codexmap.com/book.php?bookid=2848</a>

(note you will not be able to run the attached PHP directly, as I've removed some code that's not directly relevant here, and some of the globals are defined in other files). 

Good luck! 

Mark
]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/list/748.page#3614</guid>
				<link>http://forum.geonames.org/gforum/posts/list/748.page#3614</link>
				<pubDate><![CDATA[Fri, 29 Feb 2008 21:09:50]]> GMT</pubDate>
				<author><![CDATA[ Mark]]></author>
			</item>
			<item>
				<title>How to build a "Suggest" search</title>
				<description><![CDATA[ <p></p>

		<cite>Eddie wrote:</cite><br>
		<blockquote>
...
I plan to build an AJAX "Suggest" search (just like <a href="http://www.google.com/webhp?complete=1&hl=en" target="_new" rel="nofollow">Google Suggest</a>) for populated place names. In my search box a search for "b" should bring
1) countries that start with "b"
2) capitals with "b"
3) big cities with "b"
4) any other places with "b"
...
&nbsp;
		</blockquote>
it is exactly what I am looking for before I try to do it on my own  :roll: 

Any updates on this? Is it already implemented? 
(I've seen a similar stuff for country+ZIP pair, but this is not exactly what I'd need)

<b>UPD:</b> a-ha, there is a <a href="http://www.geonames.org/export/geonames-search.html" target="_new" rel="nofollow">non-documented</a> argument "name_startsWith" in "search" function! However it is not always delivering any matching results when the result do exist :-/
(<a href="http://forum.geonames.org/gforum/posts/list/1132.page" target="_new" rel="nofollow">Details in German</a>)

]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/list/748.page#5847</guid>
				<link>http://forum.geonames.org/gforum/posts/list/748.page#5847</link>
				<pubDate><![CDATA[Tue, 12 May 2009 13:59:52]]> GMT</pubDate>
				<author><![CDATA[ vak]]></author>
			</item>
	</channel>
</rss>