Boosting an optional term

15 views
Skip to first unread message

Guy Bowden

unread,
Apr 12, 2012, 4:26:33 AM4/12/12
to django-...@googlegroups.com
Hi,

I'm trying to implement a search on a subset of the geonames database. I would like matching countries to come above other matches - 

All places have an 'fcode' feature code. For a country this is 'PCLI' - 

When I do something like this:
sqs = SearchQuerySet().autocomplete(content_auto=q).boost('PCLI',1.1)

I only get country results.

content_auto is something like 'London, United Kingdom' or 'United Kingdom'

So if I search for 'United Kingdom' i get a lot of places within the UK before I get 'United Kingdom'

My index looks like this:

text = indexes.CharField(document=True, use_template=True)
    name = indexes.CharField(model_attr='formatted_name')
    alternates = indexes.CharField(model_attr='alternates')
    moddate = indexes.DateTimeField(model_attr='moddate')
    content_auto = indexes.EdgeNgramField(use_template=True)

where content_auto is {{ object.name }}, {{ object.country }}

and text is {{ object.name }} {{ object.fcode }}

Any ideas how to implement this?

Thanks,

Guy
Reply all
Reply to author
Forward
0 new messages