On Sun, Apr 22, 2007 at 08:32:21PM -0400, Ram Peters
wrote:> What is the best way to search article by location?
> For example:
> 1) I want to search only article written from South Africa
> 2) Later on, the user can narrow down the article search to specific
> city in South Africa.
>
> Do I just add doc.add_value(Country, article.origin_country)?
There are two approaches. Either you can add the location as a value
like you suggest, or you can add it as a prefixed term:
doc.add_term("XLOC:%s" % article.origin_country)
The advantages of using a term here are that it's likely to be faster,
and you can add multiple values with the same prefix (so you can add
both XLOC:UK and XLOC:London,UK as terms). With values, you'd either
have to use a second value to store the city, or use one value and have
a more complicated checking function in the MatchDecider).
Values come into their own more when you want to perform more
complicated filtering - for example, it would be pretty easy to store
lat,long in a value and filter based on distance from a specified
location.
Cheers,
Olly