I'd like to boost my query by the item's view count; I'd like to use something like view_count / max_view_count
for this purpose, to be able to measure how the item's view count relates to the biggest view count in the index. I know how to boost the results with a function query, but how can I easily get the maximum view count? If anybody could provide an example it would be very helpful...
相关问题
- JCR-SQL - contains function doesn't escape spe
- Solr Deduplication (dedupe) giving all zeros in si
- Solr (Sunspot), max results more than 30?
- Match lucene entire field exact value
- How to rank documents using tfidf similairty in lu
相关文章
- Solr - _version_ field must exist in schema and be
- SolrNet - Score always 0
- How can use the /export request handler via SolrJ?
- request counting for documents in apache solr
- How to search records between two coordinates usin
- Boost result by specified search term on top
- CakePHP with Lucene
- Faceted searching and categories in MySQL and Solr
You can add just: &stats=true&stats.field=view_count You will see a small statistics on that specified field. More documentation here
There aren't any aggregate functions under solr in the way you might be thinking about them from SQL. The easiest way to do it is to have a two-step process:
So, something like:
...to get an item with the max view_count, which you record somewhere, and then
Note that that max() function isn't doing an aggregate max; just getting the maximum of the max-view-count you pass in or 1 (to avoid divide-by-zero errors).
If you have a multiValued field (which you can't sort on) you could also use the StatsComponent to get the max. Either way, you would probably want to do this once, not for every query (say, every night at midnight or whatever once your data set settles down).