You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Rounak Jain <ro...@gmail.com> on 2013/05/23 16:50:43 UTC
Grouping results based on the field which matched the query
Hello all,
I wanted to know if Solr has some functionality to group results based on
the field that matched the query.
So if I have id, name and manufacturer in my document structure, I want to
know how many results are there because its manufacturer matched the q and
how many results are there because q matched the name field.
I understand that hit highlighting can tell me the matched field on a
per-document basis, but I want aggregated data, whose structure ideally is
like facets. (fieldname1 => number of matches, fieldname2 => number of
matches)
Rounak
Re: Grouping results based on the field which matched the query
Posted by Chris Hostetter <ho...@fucit.org>.
: I wanted to know if Solr has some functionality to group results based on
: the field that matched the query.
:
: So if I have id, name and manufacturer in my document structure, I want to
: know how many results are there because its manufacturer matched the q and
: how many results are there because q matched the name field.
there's a difference between *grouping* results by a query, and *counting*
which sbset of your request match your query.
in generla, it sounds like you are probably currently using something like
dismax or edismax to search across multiple fields, ala...
? defType=dismax & qf=name manufacturer & q=user input
if you want to count how many of each of those docs match the user input
in either name or manuacturer, you can use "facet.query" and take
advantage of local params to refer back to the users main query input...
& facet=true
& facet.query={!field f=manufacturer v=$q}
& facet.query={!field f=name v=$q}
...however i'ts important to note that those counts won't
neccessary add upto your numFound because some docs may match on
multiple fields ... you may also not get any counts if your main query
string is something complex, in qhich case you may want to ignore the
local param (v=$q) and explicitly specify what the various facet.queries
are.
likewise, if you truely want to *group* the results based on querying on a
specific field, you can use group.query instead...
https://wiki.apache.org/solr/FieldCollapsing
-Hoss
Re: Grouping results based on the field which matched the query
Posted by bbarani <bb...@gmail.com>.
Not sure if you are looking for this..
http://wiki.apache.org/solr/FieldCollapsing
--
View this message in context: http://lucene.472066.n3.nabble.com/Grouping-results-based-on-the-field-which-matched-the-query-tp4065670p4066882.html
Sent from the Solr - User mailing list archive at Nabble.com.