I went through the django-sphinx documentation , and it looks like it allows you to filter search results using attributes,
queryset = MyModel.search.query('query')
results1 = queryset.order_by('@weight', '@id', 'my_attribute')
results2 = queryset.filter(my_attribute=5)
results3 = queryset.filter(my_other_attribute=[5, 3,4])
results4 = queryset.exclude(my_attribute=5)[0:10]
In some examples, these attributes are apparently what you specify in the sphinx configuration file, and are not the actual values of the column in the table. The configuration file allows something like this,
sql_group_column = country_id
sql_group_column = state_id
sql_group_column = listings
sql_date_column = date_added
But it turns out that you can specify Foreign keys as this value. As shown in another example ,
Class City(models.Model):
...
country_id = models.ForeignKey(Country)
state_id = models.ForeignKey(State, blank=True, null=True)
listings = models.PositiveIntegerField(editable=False, default=0)
When the search result is printed, you get
print results[0]._sphinx
{'id': u'5246', 'weight': 200, 'attrs': {'state_id': 3, 'country_id': 0}}
As you can see, in attrs - state_id and country_id - being FK, are displayed. But lists do not.
. sphinx, aribtrary column foo - ?
!
,
sql_attr_uint, sql_group_column .. , , Django Sphinx (, ) _Sphinx dict if FK.. (. " " ). , SQL_Query.. .. (, *)