Summary reports using solr - solr

I need to build reports using solr (even though solr is search tool) is it possible to get an equivalent result from solr using
stats, group by and pivot. Or do I need to use nosql something like MongoDB?
select field1,field2,count(*) from TABLE1 group by field1,field2
select field1,max(field2),min(field2),count(field1),max(field3),sum(field4) from TABLE1 group by field1
I can achieve group wise stats when there is only one field in a group, not able to achieve the same when I want to group by for more than one field
Thanks in advance

Related

group by rows to get the distinct row using filter in admin-on-rest

Thanks in advance, I wanted to know is it possible to get distinct rows from db using the filter in admin-on-rest.example, for example, I want to show a list of distinct offers running but in my database, I have the duplicate offer, is it possible using filter component in admin on rest.

solr count group by

I would like to "convert" a SQL query in a solr command.
I have 2 SQL tables "jobs" and "companies".
Today to count the number of jobs published by a company, I run this query :
select c.id, count(j.id)
from companies c
left join jobs j on j.client_id = c.id
group by c.id;
In other hand I have 2 collections "jobs" and "companies" there is the same fields.
How can I "convert" the query below in solr ?
I saw it's possible to make a join with a parent collection, but I don't want to create a hierarchy between job and company (it doesn't make sense).
You can't implement a direct version of the query, as Solr doesn't do joins the way you want to do joins. A possible solution would be to facet on client_id in jobs, so you get a count for each company id, then look up values from that result when you display the counts for each company (if you really need the left join part). If the client_id isn't present in the data, its count is 0. Something like facet=true&facet.field=client_id should work.
If you only need counts for companies present in the index, I'd index the company name together with the id, so that you can facet on the name directly.

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>

query from fusion table to select rows with the most recent date

I am a newbie of javascript and fusion tables and I am setting up a project which collects and elaborates data into a google spreadsheet and then submit them to a fusion table database. The data archived have to be retrieved back into the spreadsheet with SELECT query to be used for further elaboration or to be updated and submitted again into the fusion table.
the structure of the record to be inserted and retrieved includes the following field:
field1, field2, field3, etc.
where field1 is a date/time fiedl and field2 represents a list of Countries
The query I would like to create should retrieve the subset of records including the most recent date record (field1) for each country (field2). I tried to build a SELECT query with a WHERE clause but it doesn't work. I read somewhere that this kind of problems could be solved by using a self join but I am not sure it is possible to make this kind of join in fusion tables and I don't know how to proceed.
Can anybody give me some hints or suggestions to find a solution?
Thanks in advance
Luigi

Use SOLR on Mysql relational database. Use SOLR for only product table

I am a bit confused as to where SOLR usage ends and where it begins.
I use php with a relational mysql db for a shopping site where all tables are related to the product table joining the tables as theyre queried. Needless to say its too slow!
e.g.
Category table - catid, catname, catdesc
Brand table - brandid, brandname, branddesc
Product table - productid, productname, productdesc, catid, brandid
(I also use ranges for price ranges etc)
I am wondering whether I should use SOLR to index the whole relational schema or whether just to index the product table alone and let my application work as it currently does.
If I just switch the product table to use SOLR are there any caveats to this?
e.g. in mysql I can do a fulltext search while joining the brand table. This will allow brands to also be searched upon. Is it possible to achieve the same thing just by switching the product table to SOLR? Are there any other caveats I should be looking out for.
I also would like to create a new table for "searches". This would allow me to use keywords in a mysql table in the following way:
Searches table - searchterm (e.g. lipstick), synonyms (e.g. lipstick, lips etc.)
ie. this would allow me to search upon multiple terms at the same time - a good time to use SOLR facets maybe instead of storing searches in mysql?, or should I just use mysql to store the searches and pull the products from SOLR?
Any help is gladly appreciated
NO NEED TO SWITCH
You don't want to "switch" -- just like using full-text indexing in MySQL (or using something like Sphinx), the full-text index is separate from the database tables.
What you want to do is figure out what you're searching for and index that in Solr -- it may well be just products. That's certainly an easy first step.
Basically you'll:
index the appropriate column(s) into Solr
use Solr for the searching
use the Solr results to point back to the records from the database
I'm more Ruby and Java than PHP, but you'll basically be talking to Solr for the full-text search and using that to find the records you want to display.

Resources