[postgis-users] about postgis gecode and fuzzy search
Stephen Woodbridge
woodbri at swoodbridge.com
Mon Mar 5 13:42:17 PST 2012
Hi Min,
If you are doing a fuzzy search, then you request does not make sense.
The whole purpose of a fuzzy search to to find some like what you are
looking for. What you are asking for is different. You want and exact
search with a fallback to to city centroid or zip centroid if the exact
match fails.
You could achieve this by filtering you query below like:
select * from (
SELECT g.rating, ST_X(g.geomout) As lon, ST_Y(g.geomout) As lat,
(addy).address As stno, (addy).streetname As street,
(addy).streettypeabbrev As styp, (addy).location As city,
(addy).stateabbrev As st,(addy).zip
FROM geocode('38 blair mill rod, glenside,pa') As g
) as h where h.city ilike "glenside";
Then if this fails to return a result, you could lookup the city
centroid for "glenside, pa" in another table you would need to load.
-Steve
On 3/5/2012 4:38 PM, Min Wang wrote:
> HI
> I am new to postgis geocoding.
>
> I have installed postgis 2.0 with fuzzy search, and imported the tiger
> data for usa.
>
> Now for geocoding non-exist or some not accurate addresses
>
> e.g: 38 blair mill rod, glenside, pa
>
> its output:
>
> SELECT g.rating, ST_X(g.geomout) As lon, ST_Y(g.geomout) As lat,
> (addy).address As stno, (addy).streetname As street,
> (addy).streettypeabbrev As styp, (addy).location As city,
> (addy).stateabbrev As st,(addy).zip
> FROM geocode('38 blair mill rod, glenside,pa') As g;
> rating | lon | lat | stno | street | styp | city | st | zip
> --------+-------------------+------------------+------+--------+------+------------------+----+-------
>
> 20 | -80.1461480769354 | 39.8912098295989 | 38 | Blair | Ct | Waynesburg
> | PA | 15370
> 20 | -76.9528968230038 | 41.1701753366091 | 38 | Blair | Dr | Montgomery
> | PA | 17752
> 20 | -80.1461480769354 | 39.8912098295989 | 38 | Blair | Ct | West
> Waynesburg | PA | 15370
> 20 | -80.1461480769354 | 39.8912098295989 | 38 | Blair | Ct |
> Morrisville | PA | 15370
> 20 | -77.2937928401596 | 40.2205725968637 | 38 | Blair | Ct | Plainfield
> | PA | 17015
> 21 | -78.7498163920357 | 40.467390956601 | 38 | Blair | Rd | Ebensburg |
> PA | 15931
> 22 | -80.0234909653877 | 41.4774803539524 | 38 | Blair | Ln | French
> Creek | PA | 16311
> 24 | -78.9484013917784 | 41.0336884088542 | | Blair | Dr | Reynoldsville
> | PA | 15851
> 25 | -80.236503518171 | 40.5702521235743 | 38 | Blair | Aly | South
> Heights | PA | 15081
> 27 | -75.1757087347985 | 41.0177238645261 | 38 | Blair | Ct | East
> Stroudsburg | PA | 18301
>
>
> none of them is in glenside, PA
>
> what I would like the result is: return some addresses or center in
> glenside, PA instead of other cities address?
>
> Is it possible? Is there anyway to specify the weight of the search?
>
> like city: glenside has some weight during the geocode search?
>
> the state : PA has more weight?
>
>
>
>
>
> thanks
>
>
> min
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list