GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Wildcard search  XML
Forum Index -> General
Author Message
Anonymous



Hello,
I am trying to use standard search with the JSON webservice but I cannot seem to pass wildcard arguments with the query. Example:
http://ws.geonames.org/searchJSON?q=vatic&maxRows=100&formatted=true

I've placed '%', '*', and '?' url-encoded characters but it still does not return results ('Vatican' in this example). Is there any way I am doing this wrong or are searches in boolean mode not supported yet?

Best regards,
Ligius
Anonymous



Actually, in SQL mode it looks like this:
SELECT * FROM geonames1 WHERE MATCH(asciiname) AGAINST ('vatic*' IN BOOLEAN MODE)
marc



Joined: 08/12/2005 07:39:47
Messages: 3986
Offline

Hi Ligius

Wildcards are not yet supported by the geonames search for performance and index size reasons.
There is, however, a not yet documented parameter name_startsWith for a prefix query.

http://ws.geonames.org/searchJSON?name_startsWith=vatic&formatted=true

We are not using MySQl. Do you get acceptable performance with your query?

Regards,

Marc

[WWW]
Anonymous



Thank you for the information. Here are the results of some queries using a 2Ghz P4, 1Gig RAM, Windows XP, mySQL4-something, fulltext indexing on ansiname, SQLYog as client. Further queries of the same parameter are cached, though query cache is not activated.

[ 62 ms]*/ SELECT geonameid,ansiname,name,latitude,longitude,feature_class,feature_code,country_code,admin1_code FROM geonames WHERE MATCH(ansiname) AGAINST ('timiso*' IN BOOLEAN MODE) LIMIT 100

[ 359 ms]*/ SELECT geonameid,ansiname,name,latitude,longitude,feature_class,feature_code,country_code,admin1_code FROM geonames WHERE MATCH(ansiname) AGAINST ('new york*' IN BOOLEAN MODE) LIMIT 100

[ 31 ms]*/ SELECT geonameid,ansiname,name,latitude,longitude,feature_class,feature_code,country_code,admin1_code FROM geonames WHERE MATCH(ansiname) AGAINST ('comman*' IN BOOLEAN MODE) LIMIT 100

[ 63 ms]*/ SELECT geonameid,ansiname,name,latitude,longitude,feature_class,feature_code,country_code,admin1_code FROM geonames WHERE MATCH(ansiname) AGAINST ('trepid*' IN BOOLEAN MODE) LIMIT 100

[ 375 ms]*/ SELECT geonameid,ansiname,name,latitude,longitude,feature_class,feature_code,country_code,admin1_code FROM geonames WHERE MATCH(ansiname) AGAINST ('stap*' IN BOOLEAN MODE) LIMIT 100

[ 547 ms]*/ SELECT geonameid,ansiname,name,latitude,longitude,feature_class,feature_code,country_code,admin1_code FROM geonames WHERE MATCH(ansiname) AGAINST ('london*' IN BOOLEAN MODE) LIMIT 100

[ 688 ms]*/ SELECT geonameid,ansiname,name,latitude,longitude,feature_class,feature_code,country_code,admin1_code FROM geonames WHERE MATCH(ansiname) AGAINST ('paris*' IN BOOLEAN MODE) LIMIT 100

[ 359 ms]*/ SELECT geonameid,ansiname,name,latitude,longitude,feature_class,feature_code,country_code,admin1_code FROM geonames WHERE MATCH(ansiname) AGAINST ('new york*' IN BOOLEAN MODE) LIMIT 100

Now without boolean mode enabled:

[ 687 ms]*/ SELECT geonameid,ansiname,name,latitude,longitude,feature_class,feature_code,country_code,admin1_code FROM geonames WHERE MATCH(ansiname) AGAINST ('new york') LIMIT 100

[ 406 ms]*/ SELECT geonameid,ansiname,name,latitude,longitude,feature_class,feature_code,country_code,admin1_code FROM geonames WHERE MATCH(ansiname) AGAINST ('london') LIMIT 100

[ 344 ms]*/ SELECT geonameid,ansiname,name,latitude,longitude,feature_class,feature_code,country_code,admin1_code FROM geonames WHERE MATCH(ansiname) AGAINST ('paris') LIMIT 100
...

So on my machine (developer) queries using Boolean mode typically take about the same amount of time. Sorry for the long post but as you can see performance varies randomly and cannot be judged accurately. The database is not yet deployed on the production server, but performance is expected to improve at least 10 to 100-fold.

Best regards,
Ligius
Anonymous



Is there a similar undocumented parameter for the postal code search? I would like to be able to retrieve all postal codes in a given country which begin with a particular prefix. Is this possible at this time?

Thanks,

Ben
marc



Joined: 08/12/2005 07:39:47
Messages: 3986
Offline

Hi Ben

Here you go :

http://ws.geonames.org/postalCodeSearch?postalcode_startsWith=901&maxRows=10&country=ch


Regards

Marc

[WWW]
Anonymous



Greatly appreciated!

Ben
Anonymous



is it possible using /postalcodesearch to do a placename starts with?
marc



Joined: 08/12/2005 07:39:47
Messages: 3986
Offline

Yes there is now a possibility:

http://ws.geonames.org/postalCodeSearch?placename_startsWith=menl

Regards

Marc

[WWW]
LarryFlynt



Joined: 24/07/2007 16:16:22
Messages: 10
Offline

There's a bug like this:

http://ws.geonames.org/postalCodeSearch?placename_startsWith=Ry%C5%AB%C5%8D

or

http://ws.geonames.org/postalCodeSearch?placename_startsWith=K%C3%B6l

No utf8 Support?
marc



Joined: 08/12/2005 07:39:47
Messages: 3986
Offline

Hi Larry

The first query seems to be for Japan and we don't have Japanese postal codes. This explains why we don't find anything.

The first query has a German Umlaut and it looks like a bug. I will to see why this happens. There are a couple of places where we do some tricks with German Umlauts to make sure we find both possible spellings 'oe' and 'รถ'. This could cause a problem for the 'startsWith' query.

Marc

[WWW]
LarryFlynt



Joined: 24/07/2007 16:16:22
Messages: 10
Offline

had you found it?
marc



Joined: 08/12/2005 07:39:47
Messages: 3986
Offline

Not yet. Sorry

Marc

[WWW]
LarryFlynt



Joined: 24/07/2007 16:16:22
Messages: 10
Offline

big thx for fixing it.

but now i found a error at this:
http://ws.geonames.org/postalCodeSearch?style=SHORT&maxRows=10&placename_startsWith=ber

<geonames>
<status message="maxClauseCount is set to 1024" value="12"/>
</geonames>

the maxClauseCount can deactivate if maxRows is set or?
marc



Joined: 08/12/2005 07:39:47
Messages: 3986
Offline

Hi Larry

I have fixed this as well. It had to do with the number of places starting with "Ber" and I had to rewrite the query.

Cheers

Marc

[WWW]
LarryFlynt



Joined: 24/07/2007 16:16:22
Messages: 10
Offline

thank you
LarryFlynt



Joined: 24/07/2007 16:16:22
Messages: 10
Offline

Hey marc, thx for fixing

but there's the same error at

http://ws.geonames.org/postalCodeSearch?style=SHORT&maxRows=10&postalcode_startsWith=300

and why find
http://ws.geonames.org/postalCodeSearch?style=SHORT&maxRows=10&placename_startsWith=
a result from the first character:
http://ws.geonames.org/postalCodeSearch?style=SHORT&maxRows=10&placename_startsWith=n

but this give a error:
http://ws.geonames.org/postalCodeSearch?style=SHORT&maxRows=10&postalcode_startsWith=0
marc



Joined: 08/12/2005 07:39:47
Messages: 3986
Offline

Hi Larry

I fixed these problems. let me know if there is anything else.

Cheers

Marc

[WWW]
Javier Reinoso



Joined: 24/12/2009 15:24:57
Messages: 2
Offline

One important question:

Only is Possible with startsWith?

Is not possible any how this for London, for example:

*ondo

Is only possible with the first letters, not any place that contain some letters?

For example if search for *ondo*? do results and one are London

In some countries with strange names is possible not know the first exactly letters, only some letters...

Thanks in advance for answer...
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team