Solr - Range facets are not working as expected - solr

I am trying the range facet on a field called popularity .
facet=true&facet.range=popularity&facet.range.gap=1&facet.range.start=1&facet.range.end=5.001
I am getting the below result
"popularity":{
"counts":[
"1.0",3,
"2.0",0,
"3.0",8,
"4.0",21,
"5.0",23],
But when I am adding the filter query - fq=popularity:[3 TO 4} , I am getting 11 results, I see all the results are having popularity between 3 to 4, but why when faceting on popularity it is under counting the items ?
Thanks

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.

Applying a range filter only for a particular field with specific value in SOLR

I have data indexed into solr as with fields like :-
name:Apples weight:5kg
name:Grapes weight:2kg
name:papaya weight:7kg
name:Apples weight:3kg
name:Grapes weight:3kg
I want my results to be shown in such a way that all my results except Apples comes as usual results and after that the results for apples are shown at the end that too with weight range of 4-8 kg only.
i.e the results for apples are shown at the end that too with a particular weight range.
First you'll have to limit the documents you want to your criteria - i.e. you want all documents, except for those that are apples and outside of 4-8kg (this assumes that your weight field is an integer - if it isn't - make it an integer field so that you can do proper range searches):
q=(*:* NOT name:Apples) OR (name:Apples AND weight[4 TO 8])
Then you can apply a negative boost to Apples (which you do by boosting everything that doesn't match by a large factor):
bq=(*:* -name:Apples)^1000

Solr Custom Weighted/Relevancy

I would like to do something like solr relevancy and sort by the scoring.
But the SOLR relevancy have some defined score (tf-idf).
For example:
I have boost method by field "NAME" and records returned(with score from solr and my expected score).
AA boost score 3
BB boost score 2
AB boost score 1
ID, Name, Score, Expected_Score
1, AA, 8, 3
2, AA, 6, 3
3, AA, 6, 3
4, AABB, 7, 6
5, BB, 9, 2
You can see the solr relevancy will given different score for NAME "AA" as it base on default score from query instead of only field Name. Also the most important is "BB" are given higher score compare to "AA" but the booster score is less.
I would like the scoring just base on customized field and data to boost only, without affected by others field. Similar with MySQL Weightage (ordering results based on combine weightage of fields) but in SOLR

Limit in results(docs) by facet

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

Field collapsing / Grouping - How to make SOLR return intersection of 2 resultset groups?

I have 2 fields for grouping, these 2 field can have different keywords stored in them
Ex:
Field1: CD, book, e-book
Field2: repo1, repo2, repo3, repo4
Now I want to group the combination of CD/repo1 , book/repo2, e-book/repo3,e-book/repo4,CD/repo4 rather than grouping just on field1 seperately and field2 seperately. i.e I need to group based on 2 grouped results (intersection between the grouped results). Is there a way I can make SOLR return group results for all combination?
Thanks.
BB
I don't think you can have intersection between grouped results at query time.
The other solution would be create the combination into a field at index time and use the field for grouping which would give you the results.

Resources