I'm trying to find a solution to make a subfacet list for some facets.
I have a clothes size on some products and they are stored in solr
"Size_both":"W30L30",
"Size_width":"W30",
"Size_length":"L30"
I wish to generate a list of subfacet for each width:
W30 (8)
L30 (3)
L32 (1)
L33 (4)
W32 (2)
L30 (1)
L34 (1)
etc
Anyone know how to accomplish this? I thought I could do this with group, but that didn't work.
Solr pivot faceting should do what you are asking for. If it does, you may want to be more precise on what specifically fails.
Use Facet Pivoting to achieve desired result:
Facet Pivoting
Try Below Query:
http://<host_name>:<port>/solr/<core_name>/select?q=*:*&rows=20&wt=json&indent=true&facet=true&facet.pivot=Size_width,Size_length
Related
I am running Solr 4.10.3 and trying to resort top 10 documents come from Solr. How can i do that? I am thinking of sub-query but don't know how to do that, needed help.
Example:
Suppose on query of "car" Solr return 250 documents on the basis of high score of relevancy. Now from 250 documents take top 10 documents and resort them on the basis of custom field.
i can't do that:
select?q=car&sort=score desc, pr desc
Because it will do sorting on entire 250 documents. So is there any solution?
I think you mean query reranking ? This is what is used when you want to:
use a first, more lightweight query to get a result based on the score
get a fair top x number of matches, like 2000 for example
use a heavier query to resort only those again, to get the final score
That is what you need to use if you want to do it in two steps, like you state. Now, I am not sure you need to use query reranking for your use case, maybe just boosting by that field, or sorting on a function should be enough for you.
Ive got following schema.xml
...
id
book
pages
genre (horror,action)
...
Is solr able to return results like this?
genre;books;pages
horror(genre);12(books);124543(pages)
action(genre);2(books);437(pages)
As you can see i want to facet over more than one field. The only thing i got work is the facet search over genre and books. But i want to have the pages as a sum also in my results.
Is Solr able to do this?
Thanks!
you can check for Solr Pivot Faceting which will provide you with hierarchy facets.
You can check if you get the pages, the summing can be done at Client side.
I am not sure if this is possible or what's the best way to do it? How can I get facet count in Solr where it counts as in following example.
Let's say I have got following values equal to the number of times they repeat in a field..
Tv = 100
Sony Tv = 10
LG Tv=10
Nokia Mobile= 5
iPhone Mobile = 4
If a user query is 'tv & mobile'. Based on above values in a field, How can I get the facets like...
Tv (120)
Mobile (9)
Based on the comment you gave to Jayendra's answer, you want to leverage Solr MultiValued fields to store those values and then facet on that multiValued field. This would give you the behavior you want for faceting.
Additionally, if you want to limit the facet results to a specific set of values, you will to supply a facet.query along with your request to Solr.
You can index the data in hierarchy form and use Solr Pivots to implement this facet.
e.g. tv/sony, tv/LG, mobile/Nokia & mobile/iPhone
This would help you to facet over parent and further drill down on the same.
Is there a way to get the count of different facets in solr?
This is an example facet:
Camera: 20
Computer: 80
Monitor: 40
Laptop: 120
Tablet: 30
What I need to get here is "5" as in 5 different electronic items. Of course I can count the facet but some of them have many items inside and fetching and counting them really slow it down.
You need to apply Solr Patch SOLR-2242 to get the Facet distinct count.
In SOLR 5.1 will be a "JSON Facet API" with function "unique(state)".
http://yonik.com/solr-facet-functions/
Not an exact answer to this question, but if facet distinct count doesn't work for anyone, you can get that information using group.ngroups:
group = true
group.field = [field you are faceting on]
group.ngroups = true
The disadvantage of this approach is that if you want ungrouped results, you will have to run the query a second time.
Of course the patch is recommended, but the cheesy way to do this for a simple facet, as you have here, is just to use the length of the facet divided by 2. For example, since you are faceting on type:
facetCount = facet_counts.facet_fields.type.length/2
Use this GET request:
http://localhost:8983/solr/core_name/select?json.facet={x:"unique(electronic_items)"}&q=*:*&rows=0
I have problems with faceting. Imagine this situation. Product can be in more than one category. This is common behavior for faceting:
Category
Android (25)
iPhone (55)
other (25)
Now when I select "Android", I make new query with "fq" => "category:Android", I will get:
Category
Android
iPhone (15)
other (2)
But this means that there is 15 products, that are in categories "Android" AND "iPhone". I would like something like this: ("Android" OR "iPhone")
Category
Android
iPhone (+5)
other (+1)
Meaning I will get 25 results by selecting "Android (25)" and another 5 by selecting "iPhone (+5)", so finally I will get 30 search results..
Does anyone know if this is possible with SOLR's faceting? Or perhaps with more than one query and calculate it manually?
Thanks for advice!
Try a new query with the negative of the selections, like "fq" => "-category:Android" - you should then get the facet counts you are looking for.
Depending on all the permutations you need, you probably want to look into query facets that enable you to get counts for arbitrary queries. For instance, you can do facet.query=category:("Android" OR "iPhone") and get a count results keyed on category:("Android" OR "iPhone"). And, you can do this for any number of queries you want counts for. So, in your case, you can probably get to a final solution with some combination of straight field facets and query facets.
Edit: Re-reading you question, you may also want to look into tagging and excluding parts of an extra fq, depending on how you are allowing your users to "select into" the choices. (The example in the docs is fairly close to your original setup, although I'm not sure the end behavior is exactly as you desire).