Limit in results(docs) by facet - solr

I want to show max 5 results(docs) from each facets on first page. How can I achieve it in Solr 4.x
for e.g I have thousands of matching products(docs) in TV, Music System, Books etc categories. If I search "Music" keyword, I should get max 5 matching results(docs) from all categories.
Thanks in advance.
Edit: I want to set limit on results(docs) not on facet list. And this limit is on each facet not on all result. If there are 3 categories, 15 results(docs) can be display on page, if 4, max 20 results(docs) can be display.

To limit search results you need to use param rows=5
For more info - http://wiki.apache.org/solr/CommonQueryParameters#rows

Related

Solr Boost-Function on Sales

I am using Apache Solr 8 with products as documents. Each document includes sales within the last X days that I want to boost, as well as a title and other fields.
Say productA has been sold 5 times, I want to boost it with score+10; a productB has been sold 50 times, I want to boost the score by 30.
I tried to use a boostFunction that looks like (edismax query parser)
q=Coffee&qf=title&bf=if(lt(sales,5),10,if(lt(sales,50),30))
Solr now returns documents that have nothing to do with my "Coffee"-Query but just match the boostfunction. There are even results with score "0".
E.g.
Rank;Score;Sales;Title
1;58.53;55;Coffee big
2;38.11;50;Coffee
3;30;55;Tea
Any idea to get rid of those "only boost function"-matches?
Found the answer!
My Query-Fields actually included boostings like
&qf=title^2 longDescription^0 whatever^0...
Instead of excluding the results found in those 0-boosted fields, solr adds them and matches with - well score 0.
When I remove the 0-boostings, everything works as intended.

Solr facet offset by term/prefix rather than index

I'm generating facet counts for a multivalued field and sorting them by index in order to see them in alphabetical order. Given a particular facet prefix, I would like to jump to its place in the facet count list and show the facet counts surrounding it. For example, if my prefix is "wha" then I would want the following returned (four before and four after):
weld 1
welsh 5
west 4
wetland 1
whale 99
wheat 123
wheel 1
whey 9
There are millions of values in the field and so I can't just ask for them all. I need to be able to jump to that location or use some kind of filter on the facet counts themselves. I've tried using facet.offset, but I have to basically do a binary search in order to find the appropriate offset which is too slow.
I could probably get close enough if I could put in a range for a facet prefix. For example facet.prefix=[we TO wk] or even multiple prefixes like facet.prefix=we,wf,wg,wh,wi,wj,wk.
I'm currently using other non-Solr solutions to accomplish this, but I would like to use Solr 6.6 in order to take advantage of filter queries.

Solr: Searching a term in multiple, indexed fields and returning top 'N' hits from each search field

I have two indexed fields in my Solr schema
Employee Name
Manager Name
Which are plain strings.
my Question is: Given a search term, I want to display top 5 suggested completions from Manager Names and the next 5 from Employee Names.
I can use copy fields, but sometimes I get all top 10 results from Employee Names.
I have a hunch that boosting can help me.. but could not figure out how?
Boost can't help you control the results and distribute 5 each in the top 10 results.
Probably you can check on Field Collapsing, where you can group per role (Manager and Name) and limit 5 results for the group.
So you would have 2 groups returned back to you with 5 results each.

Setting up facets in SOLR

I am using solr and I want to setup two different types of facets on my data. The first is date, so I would like it like this:
Posted:
Today
3 days
7 days
All time
Distance:
5 miles
10 miles
30 miles
100 miles
How should I be setting up faceting? It looks like something I need to edit my solr.xml or my schema.xml but it is all very confusing and the help documents boggle my mind.
Can someone who has done this before give me a bit of guidance please?
facet.query: This parameter can be specified multiple times to indicate that multiple queries should be used as separate facet constraints. So you can do distance:[* TO 5], distance:[5 TO 10] and you will get the individual counts.
Then there is facet.date and facet.range which may better suit you.

Solr - Sort search result based on facet count

I have information of products in Solr and each product is under a category. I would like to sort product search result based on facet count on Category. So if there are 100 products matching criteria under Electronics category and 50 products under Books, I would like to sort the result(or boost) the way that I see first 100 electronics and then 50 books.
Is it possible with one query?
Thanks.
I don't think this is possible; faceting does not influence search results.

Resources