Solr stats facet left out some values - solr

I want to facet over products in Solr and want to retrieve statistics about the categories.
My schema has got a field called categories, a multiValued field.
the problem is, that the statistics left out a bunch of categories. Am I wrong with following query? Obviously, but how do I make it right? Pleeeease help, I'm despairing.
q=*:*&rows=0&stats=true&stats.field=product_id&rows=0&stats.facet=categories

The query looks fine, the problem is that it's faceting on a multiValued field:
http://wiki.apache.org/solr/StatsComponent
Computing statistics using stats.facet over a multi-valued field does
not work properly.
https://issues.apache.org/jira/browse/SOLR-1782
Hope this helps!

Related

How to approach a hierarchical search in Solr?

I'm trying to understand how to approach search requirements I have.
The first one is a normal product search that I know Solr can handle appropriately, where you search for a term and Solr returns relevant documents.
The second one is a search for products within a certain category. I have a hierarchical structure in my database that consists in a category with many subcategories and those have products.
The thing is, when some very specific words are searched for, the first approach shouldn't be used, instead a search for a category should be done and only products within that category should be returned, which for me is a very basic SQL query (select * from products where categoryId = 1000).
Does Solr should or can be used in the second case? If so, what is the normal approach to use?
Besides what #Mysterion proposed of filter queries you should take a look at Solr Facets which gives you very powerful catogory-like searching.
You also might want to consider multivalue field for categoryParentIds which will contain the parent categories that the product is in and thus combined with filter query and or facets will get your parent category searching.
Yes, you could use similar approach in Solr, by attributing your products with categoryId and later, while searching add filter query similiar to SQL, categoryId:10000
For more info about filter query, take a look here - http://wiki.apache.org/solr/CommonQueryParameters#fq

Can Solr use field values of a known document in a query?

I would like to perform a Solr search using the values of certain fields of an indexed document which I can identify by its id. With MLT this is somehow possible, but I would prefer a regular query parser. Can I somehow use subqueries to inject the result of a subquery into the main query?
For example, let's say I have indexed information about books into solr, where each document represents a book, with an id, title and author field. At query time I have only the document id availible and I would like to search for books by the same author in a single step. Is this possible without using MLT?
You can use JOIN.
http://HOST:PORT/CORE/select?q={!join from=author to=author}id:<ID>

Get possible facet fields with search results

I'm working on improving search which is powered by solr for my e-commerce project. So search queries are performed into Solr and results are returned by Solr.
This is working fine. Now I need to offer a facet on the search results. The first could be category this is easy to implement as Category is common to all product and in the query I make I just enable facet and pass category as facet field.
However, for different nature of products there could be different products and they have few facets defined for them.
I'm clueless as how would I know them in advance and pass it in solr search query? Does solr return all facet field by some queries along with the search results? If yes, how?
If no, then what could be the correct way to proceed further.
Pass all Unique Facet Field Name on which you want to make facet filtering, and you will get all records that have facet field.
Define all the static fieldnames in your facet query search, if there are no hits you will not get any results back for that field.
Pass all the possible fields(on which u need faceting) in Facet Field with facet.mincount=1.. so, you'll get only those fields which has at-least one occurrence in your solr data
http://<hostname>:<portname>/solr/<core_name>/select?q:<fieldname>:<value>&fq=<field_name>:<value>&fl=<field1>,<field2>,<fieldn>&start=0&rows=10&facet=true&facet.field=<field1>&facet.field=<field2>&facet.field=<fieldn>&facet.mincount=1

Is there any way to convert a solr multifield value to single field for sort?

I have records that have multiple values so I put those fields in a multifield value for its solr document. The issue is I also need to return an ordered list of these values. I have way to many records to pull all document values and sort myself. I tried to create separate solr documents to store just these values with needed information but managing this has become a nightmare. Attempting to keep comments low and managing memory has not been ideal for this solution.
Is there anyway to copy these multifield values into single field values for the same document and sort on these multiple single field values in solr?
Thanks for any help.
doesn't faceting help you? you won't need to have a copyfield for multivalued/non-multivalued, just store them in a multivalued field, facet them and set the sorting criteria for the facet (default: number of occurrencies for each value)

Solr Faceting result with more than just count

This is my requirment:
I have a list of products indexed in Solr and categoryid, category name and category alias are MultiValued fields.
I would like to do faceting on category but want the faceting result to have all categoryID, CategoryName and Category Alias along with the count number.
Is this possible? Or I have to do faceting only for CategoryID and with another request or query to our SQL server database get the rest of the information of that CategoryID?
If a slight increase in index size doesn't matter to you, you're able to change the schema, and you're able to do a full reindex, then add a new field 'categoryFacet' for this. This new field would hold the information you described in your question.
Most likely, you'll solve this by editing the SELECT statement you use for indexing.
Base on the set up in solrconfig,xml, you get back a list of facet value and count. When you select a facet, you'll get back results with all fields you defined in the schema.xml. I'm not aware of anything would allow facet to return more than facet value and count. What's your goal? Is it to display categoryName, categoryId and categoryAlias together as facet to end user? or is it something else? It'll be easier for people to help you if you state your goal clearly. I'm not sure if you checkout the wiki for facet already.
http://wiki.apache.org/solr/SimpleFacetParameters#facet

Resources