Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
s = SphinxClient()
s.SetGroupBy('tags', SPH_GROUPBY_ATTR, "@count desc" )
tags = s.Query('', index=index)
doc {
id : 1
keywords: [ hello, world ]
...
}
# Example: for the following input
id,tags
101,"movie,spiderman,action"
#to index the 3 separate tags into a multi-valued Solr field called "tags", use
f.tags.split=true
'{"title" : "One", "tags" : ["foo"]}'
'{"title" : "Two", "tags" : ["foo", "bar"]}'
'{"title" : "Three", "tags" : ["foo", "bar", "baz"]}'
"facets" : {
"tags" : {
"_type" : "terms",
"missing" : 0,
"total": 5,
"other": 0,
"terms" : [ {
"term" : "foo",
"count" : 2
}, {
"term" : "bar",
"count" : 2
}, {
"term" : "baz",
"count" : 1
} ]
}
}
s = SphinxClient()
s.SetGroupBy('tags', SPH_GROUPBY_ATTR, "@count desc" )
tags = s.Query('', index=index)
tags = [(x['attrs']['tags'], x['attrs']['@count']) for x in tags['matches']]
print tags
{'django': 100, 'sphinx': 30}
'@count': 5,
'@groupby': 7,
'tags': [7, 8]
jango+sphinx = jango-sphinx
Django + Sphinx = django-sphinx (?)