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 Cristian Popovici <cr...@visionsr.com> on 2017/02/05 09:49:35 UTC

Find groups where at least one item matches a query

Hi all,

I'm new to Solr and I need a bit of help.

I have a structure of documents indexed in Solr that are grouped together
by a property. I need to retrieve all groups where at least one entry in
the group matches a query.

Example:
I have two documents indexed and both share the *groupId *property that
defines the grouping field.

*{*
*        "groupId": "223",*
*        "modality": "Computed Tomography",*
*        "anatomy": "Subcutaneous fat",*
*        "pathology": "Metastasis",*
*}*

*{*
*        "groupId": "223",*
*        "modality": "Computed Tomography",*
*        "anatomy": "Subcutaneous fat",*
*        "pathology": "Normal",*
*}*

I need to retrieve both entries in the group when performing a query like:

*(pathology:Normal)*
Is this possible in solr?

Thanks!

Re: Find groups where at least one item matches a query

Posted by Joel Bernstein <jo...@gmail.com>.
Assuming you have a unique id for each document the graph expression below
will get you what you're looking for.

The nodes function is short for gatherNodes described in the docs (
https://cwiki.apache.org/confluence/display/solr/Graph+Traversal). Starting
in 6.4 you can call the function "nodes" or "gatherNodes".

nodes(collection,
           nodes(collection,
                      walk="Normal->pathology",
                      gather="groupId"),
           walk="node->groupId",
           gather="id",
           trackTraversal="true")


The inner nodes function retrieves all the groupId's where Normal is the
pathology. The outer nodes function takes the groupId's emitted from the
inner nodes function and retrieves all the document id's in these groups.
trackTraversal=true on the outer nodes function will include the "groupId"
in the ancestor field of each doc id.

You'll find that when master the graph expression syntax you'll be able to
do all kinds of interesting graph queries on the data set you've described,
which is really a best treated as a graph.



Joel Bernstein
http://joelsolr.blogspot.com/

On Sun, Feb 5, 2017 at 10:24 PM, Joel Bernstein <jo...@gmail.com> wrote:

> Take a look at the graph expressions:
>
> https://cwiki.apache.org/confluence/display/solr/Graph+Traversal
>
> Joel Bernstein
> http://joelsolr.blogspot.com/
>
> On Sun, Feb 5, 2017 at 3:43 PM, Alexandre Rafalovitch <ar...@gmail.com>
> wrote:
>
>> What about collapse and expand with overriden query. Something like
>> this (against 6.4 techproducts example):
>> http://localhost:8983/solr/techproducts/select?expand.q=*:*&
>> expand=true&fq={!collapse%20field=manu_id_s}&indent=on&q=
>> name:CORSAIR&wt=json
>> <http://localhost:8983/solr/techproducts/select?expand.q=*:*&expand=true&fq=%7B!collapse%20field=manu_id_s%7D&indent=on&q=name:CORSAIR&wt=json>
>>
>> Note that the main document area contains the head document and the
>> expanded area contains the rest of them, up to provided/default limit.
>> For further info, see
>> https://cwiki.apache.org/confluence/display/solr/Collapse+
>> and+Expand+Results
>>
>> Regards,
>>    Alex.
>> ----
>> http://www.solr-start.com/ - Resources for Solr users, new and
>> experienced
>>
>>
>> On 5 February 2017 at 14:55, Cristian Popovici
>> <cr...@visionsr.com> wrote:
>> > Doesn't seem to work - I'm doing a query like this and I get only one
>> result
>> >
>> > q=pathology:normal&group=true&group.field=groupId&*group.limit=2*
>> >
>> > On Sun, Feb 5, 2017 at 7:20 PM, Nick Vasilyev <nick.vasilyev1@gmail.com
>> >
>> > wrote:
>> >
>> >> Check out the group.limit argument.
>> >>
>> >> On Feb 5, 2017 12:10 PM, "Cristian Popovici" <
>> cristi.popovici@visionsr.com
>> >> >
>> >> wrote:
>> >>
>> >> > Erick, thanks for you answer.
>> >> >
>> >> > Sorry - I forgot to mention that I do not know the group id when I
>> >> perform
>> >> > the query.
>> >> > Grouping - I think - does not help for me as it filters out the
>> documents
>> >> > that do not meet the filter criteria.
>> >> >
>> >> > Example:
>> >> > *q=pathology:Normal&group=true&group.field=groupId*  will miss out
>> the
>> >> > "pathology":
>> >> > "Metastasis".
>> >> >
>> >> > I need to retrieve both documents in the same group even if only one
>> >> meets
>> >> > the search criteria.
>> >> >
>> >> > Thanks!
>> >> >
>> >> > On Sun, Feb 5, 2017 at 6:54 PM, Erick Erickson <
>> erickerickson@gmail.com>
>> >> > wrote:
>> >> >
>> >> > > Isn't this just "&fq=groupId:223"?
>> >> > >
>> >> > > Or do you mean you need multiple _groups_? In which case you can
>> use
>> >> > > grouping, see:
>> >> > > https://cwiki.apache.org/confluence/display/solr/
>> >> > > Collapse+and+Expand+Results
>> >> > > and/or
>> >> > > https://cwiki.apache.org/confluence/display/solr/Result+Grouping
>> >> > >
>> >> > > but do note there are some limitations in distributed mode.
>> >> > >
>> >> > > Best,
>> >> > > Erick
>> >> > >
>> >> > > On Sun, Feb 5, 2017 at 1:49 AM, Cristian Popovici
>> >> > > <cr...@visionsr.com> wrote:
>> >> > > > Hi all,
>> >> > > >
>> >> > > > I'm new to Solr and I need a bit of help.
>> >> > > >
>> >> > > > I have a structure of documents indexed in Solr that are grouped
>> >> > together
>> >> > > > by a property. I need to retrieve all groups where at least one
>> entry
>> >> > in
>> >> > > > the group matches a query.
>> >> > > >
>> >> > > > Example:
>> >> > > > I have two documents indexed and both share the *groupId
>> *property
>> >> that
>> >> > > > defines the grouping field.
>> >> > > >
>> >> > > > *{*
>> >> > > > *        "groupId": "223",*
>> >> > > > *        "modality": "Computed Tomography",*
>> >> > > > *        "anatomy": "Subcutaneous fat",*
>> >> > > > *        "pathology": "Metastasis",*
>> >> > > > *}*
>> >> > > >
>> >> > > > *{*
>> >> > > > *        "groupId": "223",*
>> >> > > > *        "modality": "Computed Tomography",*
>> >> > > > *        "anatomy": "Subcutaneous fat",*
>> >> > > > *        "pathology": "Normal",*
>> >> > > > *}*
>> >> > > >
>> >> > > > I need to retrieve both entries in the group when performing a
>> query
>> >> > > like:
>> >> > > >
>> >> > > > *(pathology:Normal)*
>> >> > > > Is this possible in solr?
>> >> > > >
>> >> > > > Thanks!
>> >> > >
>> >> >
>> >>
>>
>
>

Re: Find groups where at least one item matches a query

Posted by Joel Bernstein <jo...@gmail.com>.
Take a look at the graph expressions:

https://cwiki.apache.org/confluence/display/solr/Graph+Traversal

Joel Bernstein
http://joelsolr.blogspot.com/

On Sun, Feb 5, 2017 at 3:43 PM, Alexandre Rafalovitch <ar...@gmail.com>
wrote:

> What about collapse and expand with overriden query. Something like
> this (against 6.4 techproducts example):
> http://localhost:8983/solr/techproducts/select?expand.q=*
> :*&expand=true&fq={!collapse%20field=manu_id_s}&indent=on&
> q=name:CORSAIR&wt=json
>
> Note that the main document area contains the head document and the
> expanded area contains the rest of them, up to provided/default limit.
> For further info, see
> https://cwiki.apache.org/confluence/display/solr/
> Collapse+and+Expand+Results
>
> Regards,
>    Alex.
> ----
> http://www.solr-start.com/ - Resources for Solr users, new and experienced
>
>
> On 5 February 2017 at 14:55, Cristian Popovici
> <cr...@visionsr.com> wrote:
> > Doesn't seem to work - I'm doing a query like this and I get only one
> result
> >
> > q=pathology:normal&group=true&group.field=groupId&*group.limit=2*
> >
> > On Sun, Feb 5, 2017 at 7:20 PM, Nick Vasilyev <ni...@gmail.com>
> > wrote:
> >
> >> Check out the group.limit argument.
> >>
> >> On Feb 5, 2017 12:10 PM, "Cristian Popovici" <
> cristi.popovici@visionsr.com
> >> >
> >> wrote:
> >>
> >> > Erick, thanks for you answer.
> >> >
> >> > Sorry - I forgot to mention that I do not know the group id when I
> >> perform
> >> > the query.
> >> > Grouping - I think - does not help for me as it filters out the
> documents
> >> > that do not meet the filter criteria.
> >> >
> >> > Example:
> >> > *q=pathology:Normal&group=true&group.field=groupId*  will miss out
> the
> >> > "pathology":
> >> > "Metastasis".
> >> >
> >> > I need to retrieve both documents in the same group even if only one
> >> meets
> >> > the search criteria.
> >> >
> >> > Thanks!
> >> >
> >> > On Sun, Feb 5, 2017 at 6:54 PM, Erick Erickson <
> erickerickson@gmail.com>
> >> > wrote:
> >> >
> >> > > Isn't this just "&fq=groupId:223"?
> >> > >
> >> > > Or do you mean you need multiple _groups_? In which case you can use
> >> > > grouping, see:
> >> > > https://cwiki.apache.org/confluence/display/solr/
> >> > > Collapse+and+Expand+Results
> >> > > and/or
> >> > > https://cwiki.apache.org/confluence/display/solr/Result+Grouping
> >> > >
> >> > > but do note there are some limitations in distributed mode.
> >> > >
> >> > > Best,
> >> > > Erick
> >> > >
> >> > > On Sun, Feb 5, 2017 at 1:49 AM, Cristian Popovici
> >> > > <cr...@visionsr.com> wrote:
> >> > > > Hi all,
> >> > > >
> >> > > > I'm new to Solr and I need a bit of help.
> >> > > >
> >> > > > I have a structure of documents indexed in Solr that are grouped
> >> > together
> >> > > > by a property. I need to retrieve all groups where at least one
> entry
> >> > in
> >> > > > the group matches a query.
> >> > > >
> >> > > > Example:
> >> > > > I have two documents indexed and both share the *groupId *property
> >> that
> >> > > > defines the grouping field.
> >> > > >
> >> > > > *{*
> >> > > > *        "groupId": "223",*
> >> > > > *        "modality": "Computed Tomography",*
> >> > > > *        "anatomy": "Subcutaneous fat",*
> >> > > > *        "pathology": "Metastasis",*
> >> > > > *}*
> >> > > >
> >> > > > *{*
> >> > > > *        "groupId": "223",*
> >> > > > *        "modality": "Computed Tomography",*
> >> > > > *        "anatomy": "Subcutaneous fat",*
> >> > > > *        "pathology": "Normal",*
> >> > > > *}*
> >> > > >
> >> > > > I need to retrieve both entries in the group when performing a
> query
> >> > > like:
> >> > > >
> >> > > > *(pathology:Normal)*
> >> > > > Is this possible in solr?
> >> > > >
> >> > > > Thanks!
> >> > >
> >> >
> >>
>

Re: Find groups where at least one item matches a query

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
As per the documentation:
"So all downstream components (faceting, highlighting, etc...) will
work with the collapsed result set."

So, no, you cannot facet on expanded group. Partially because it is
not really fully expanded (there is a limit of items in each group).

But also, are trying to facet per group or globally? If globally,
maybe you can override the faceting query or have a custom component
(before facet one) that generates facet.query parameters based on what
you got back from collapsing.

If locally, maybe there is something in json.facet module to do nested
facet for each domain.

Or maybe it is worth running two queries, one for results and one for
facets.....

Regards,
   Alex.
----
http://www.solr-start.com/ - Resources for Solr users, new and experienced


On 8 February 2017 at 16:02, Cristian Popovici
<cr...@visionsr.com> wrote:
> Alexander - thanks! It seems to work great.
>
> I still have a question - if I want to do a facet query that includes also
> the documents in the expanded area. Is this possible? If I apply a facet
> query like "facet=true&facet.field=modality" it counts only the head
> documents.
>
> Thanks,
> Cristian.
>
> On Sun, Feb 5, 2017 at 10:43 PM, Alexandre Rafalovitch <ar...@gmail.com>
> wrote:
>
>> What about collapse and expand with overriden query. Something like
>> this (against 6.4 techproducts example):
>> http://localhost:8983/solr/techproducts/select?expand.q=*
>> :*&expand=true&fq={!collapse%20field=manu_id_s}&indent=on&
>> q=name:CORSAIR&wt=json
>>
>> Note that the main document area contains the head document and the
>> expanded area contains the rest of them, up to provided/default limit.
>> For further info, see
>> https://cwiki.apache.org/confluence/display/solr/
>> Collapse+and+Expand+Results
>>
>> Regards,
>>    Alex.
>> ----
>> http://www.solr-start.com/ - Resources for Solr users, new and experienced
>>
>>
>> On 5 February 2017 at 14:55, Cristian Popovici
>> <cr...@visionsr.com> wrote:
>> > Doesn't seem to work - I'm doing a query like this and I get only one
>> result
>> >
>> > q=pathology:normal&group=true&group.field=groupId&*group.limit=2*
>> >
>> > On Sun, Feb 5, 2017 at 7:20 PM, Nick Vasilyev <ni...@gmail.com>
>> > wrote:
>> >
>> >> Check out the group.limit argument.
>> >>
>> >> On Feb 5, 2017 12:10 PM, "Cristian Popovici" <
>> cristi.popovici@visionsr.com
>> >> >
>> >> wrote:
>> >>
>> >> > Erick, thanks for you answer.
>> >> >
>> >> > Sorry - I forgot to mention that I do not know the group id when I
>> >> perform
>> >> > the query.
>> >> > Grouping - I think - does not help for me as it filters out the
>> documents
>> >> > that do not meet the filter criteria.
>> >> >
>> >> > Example:
>> >> > *q=pathology:Normal&group=true&group.field=groupId*  will miss out
>> the
>> >> > "pathology":
>> >> > "Metastasis".
>> >> >
>> >> > I need to retrieve both documents in the same group even if only one
>> >> meets
>> >> > the search criteria.
>> >> >
>> >> > Thanks!
>> >> >
>> >> > On Sun, Feb 5, 2017 at 6:54 PM, Erick Erickson <
>> erickerickson@gmail.com>
>> >> > wrote:
>> >> >
>> >> > > Isn't this just "&fq=groupId:223"?
>> >> > >
>> >> > > Or do you mean you need multiple _groups_? In which case you can use
>> >> > > grouping, see:
>> >> > > https://cwiki.apache.org/confluence/display/solr/
>> >> > > Collapse+and+Expand+Results
>> >> > > and/or
>> >> > > https://cwiki.apache.org/confluence/display/solr/Result+Grouping
>> >> > >
>> >> > > but do note there are some limitations in distributed mode.
>> >> > >
>> >> > > Best,
>> >> > > Erick
>> >> > >
>> >> > > On Sun, Feb 5, 2017 at 1:49 AM, Cristian Popovici
>> >> > > <cr...@visionsr.com> wrote:
>> >> > > > Hi all,
>> >> > > >
>> >> > > > I'm new to Solr and I need a bit of help.
>> >> > > >
>> >> > > > I have a structure of documents indexed in Solr that are grouped
>> >> > together
>> >> > > > by a property. I need to retrieve all groups where at least one
>> entry
>> >> > in
>> >> > > > the group matches a query.
>> >> > > >
>> >> > > > Example:
>> >> > > > I have two documents indexed and both share the *groupId *property
>> >> that
>> >> > > > defines the grouping field.
>> >> > > >
>> >> > > > *{*
>> >> > > > *        "groupId": "223",*
>> >> > > > *        "modality": "Computed Tomography",*
>> >> > > > *        "anatomy": "Subcutaneous fat",*
>> >> > > > *        "pathology": "Metastasis",*
>> >> > > > *}*
>> >> > > >
>> >> > > > *{*
>> >> > > > *        "groupId": "223",*
>> >> > > > *        "modality": "Computed Tomography",*
>> >> > > > *        "anatomy": "Subcutaneous fat",*
>> >> > > > *        "pathology": "Normal",*
>> >> > > > *}*
>> >> > > >
>> >> > > > I need to retrieve both entries in the group when performing a
>> query
>> >> > > like:
>> >> > > >
>> >> > > > *(pathology:Normal)*
>> >> > > > Is this possible in solr?
>> >> > > >
>> >> > > > Thanks!
>> >> > >
>> >> >
>> >>
>>

Re: Find groups where at least one item matches a query

Posted by Cristian Popovici <cr...@visionsr.com>.
Alexander - thanks! It seems to work great.

I still have a question - if I want to do a facet query that includes also
the documents in the expanded area. Is this possible? If I apply a facet
query like "facet=true&facet.field=modality" it counts only the head
documents.

Thanks,
Cristian.

On Sun, Feb 5, 2017 at 10:43 PM, Alexandre Rafalovitch <ar...@gmail.com>
wrote:

> What about collapse and expand with overriden query. Something like
> this (against 6.4 techproducts example):
> http://localhost:8983/solr/techproducts/select?expand.q=*
> :*&expand=true&fq={!collapse%20field=manu_id_s}&indent=on&
> q=name:CORSAIR&wt=json
>
> Note that the main document area contains the head document and the
> expanded area contains the rest of them, up to provided/default limit.
> For further info, see
> https://cwiki.apache.org/confluence/display/solr/
> Collapse+and+Expand+Results
>
> Regards,
>    Alex.
> ----
> http://www.solr-start.com/ - Resources for Solr users, new and experienced
>
>
> On 5 February 2017 at 14:55, Cristian Popovici
> <cr...@visionsr.com> wrote:
> > Doesn't seem to work - I'm doing a query like this and I get only one
> result
> >
> > q=pathology:normal&group=true&group.field=groupId&*group.limit=2*
> >
> > On Sun, Feb 5, 2017 at 7:20 PM, Nick Vasilyev <ni...@gmail.com>
> > wrote:
> >
> >> Check out the group.limit argument.
> >>
> >> On Feb 5, 2017 12:10 PM, "Cristian Popovici" <
> cristi.popovici@visionsr.com
> >> >
> >> wrote:
> >>
> >> > Erick, thanks for you answer.
> >> >
> >> > Sorry - I forgot to mention that I do not know the group id when I
> >> perform
> >> > the query.
> >> > Grouping - I think - does not help for me as it filters out the
> documents
> >> > that do not meet the filter criteria.
> >> >
> >> > Example:
> >> > *q=pathology:Normal&group=true&group.field=groupId*  will miss out
> the
> >> > "pathology":
> >> > "Metastasis".
> >> >
> >> > I need to retrieve both documents in the same group even if only one
> >> meets
> >> > the search criteria.
> >> >
> >> > Thanks!
> >> >
> >> > On Sun, Feb 5, 2017 at 6:54 PM, Erick Erickson <
> erickerickson@gmail.com>
> >> > wrote:
> >> >
> >> > > Isn't this just "&fq=groupId:223"?
> >> > >
> >> > > Or do you mean you need multiple _groups_? In which case you can use
> >> > > grouping, see:
> >> > > https://cwiki.apache.org/confluence/display/solr/
> >> > > Collapse+and+Expand+Results
> >> > > and/or
> >> > > https://cwiki.apache.org/confluence/display/solr/Result+Grouping
> >> > >
> >> > > but do note there are some limitations in distributed mode.
> >> > >
> >> > > Best,
> >> > > Erick
> >> > >
> >> > > On Sun, Feb 5, 2017 at 1:49 AM, Cristian Popovici
> >> > > <cr...@visionsr.com> wrote:
> >> > > > Hi all,
> >> > > >
> >> > > > I'm new to Solr and I need a bit of help.
> >> > > >
> >> > > > I have a structure of documents indexed in Solr that are grouped
> >> > together
> >> > > > by a property. I need to retrieve all groups where at least one
> entry
> >> > in
> >> > > > the group matches a query.
> >> > > >
> >> > > > Example:
> >> > > > I have two documents indexed and both share the *groupId *property
> >> that
> >> > > > defines the grouping field.
> >> > > >
> >> > > > *{*
> >> > > > *        "groupId": "223",*
> >> > > > *        "modality": "Computed Tomography",*
> >> > > > *        "anatomy": "Subcutaneous fat",*
> >> > > > *        "pathology": "Metastasis",*
> >> > > > *}*
> >> > > >
> >> > > > *{*
> >> > > > *        "groupId": "223",*
> >> > > > *        "modality": "Computed Tomography",*
> >> > > > *        "anatomy": "Subcutaneous fat",*
> >> > > > *        "pathology": "Normal",*
> >> > > > *}*
> >> > > >
> >> > > > I need to retrieve both entries in the group when performing a
> query
> >> > > like:
> >> > > >
> >> > > > *(pathology:Normal)*
> >> > > > Is this possible in solr?
> >> > > >
> >> > > > Thanks!
> >> > >
> >> >
> >>
>

Re: Find groups where at least one item matches a query

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
What about collapse and expand with overriden query. Something like
this (against 6.4 techproducts example):
http://localhost:8983/solr/techproducts/select?expand.q=*:*&expand=true&fq={!collapse%20field=manu_id_s}&indent=on&q=name:CORSAIR&wt=json

Note that the main document area contains the head document and the
expanded area contains the rest of them, up to provided/default limit.
For further info, see
https://cwiki.apache.org/confluence/display/solr/Collapse+and+Expand+Results

Regards,
   Alex.
----
http://www.solr-start.com/ - Resources for Solr users, new and experienced


On 5 February 2017 at 14:55, Cristian Popovici
<cr...@visionsr.com> wrote:
> Doesn't seem to work - I'm doing a query like this and I get only one result
>
> q=pathology:normal&group=true&group.field=groupId&*group.limit=2*
>
> On Sun, Feb 5, 2017 at 7:20 PM, Nick Vasilyev <ni...@gmail.com>
> wrote:
>
>> Check out the group.limit argument.
>>
>> On Feb 5, 2017 12:10 PM, "Cristian Popovici" <cristi.popovici@visionsr.com
>> >
>> wrote:
>>
>> > Erick, thanks for you answer.
>> >
>> > Sorry - I forgot to mention that I do not know the group id when I
>> perform
>> > the query.
>> > Grouping - I think - does not help for me as it filters out the documents
>> > that do not meet the filter criteria.
>> >
>> > Example:
>> > *q=pathology:Normal&group=true&group.field=groupId*  will miss out the
>> > "pathology":
>> > "Metastasis".
>> >
>> > I need to retrieve both documents in the same group even if only one
>> meets
>> > the search criteria.
>> >
>> > Thanks!
>> >
>> > On Sun, Feb 5, 2017 at 6:54 PM, Erick Erickson <er...@gmail.com>
>> > wrote:
>> >
>> > > Isn't this just "&fq=groupId:223"?
>> > >
>> > > Or do you mean you need multiple _groups_? In which case you can use
>> > > grouping, see:
>> > > https://cwiki.apache.org/confluence/display/solr/
>> > > Collapse+and+Expand+Results
>> > > and/or
>> > > https://cwiki.apache.org/confluence/display/solr/Result+Grouping
>> > >
>> > > but do note there are some limitations in distributed mode.
>> > >
>> > > Best,
>> > > Erick
>> > >
>> > > On Sun, Feb 5, 2017 at 1:49 AM, Cristian Popovici
>> > > <cr...@visionsr.com> wrote:
>> > > > Hi all,
>> > > >
>> > > > I'm new to Solr and I need a bit of help.
>> > > >
>> > > > I have a structure of documents indexed in Solr that are grouped
>> > together
>> > > > by a property. I need to retrieve all groups where at least one entry
>> > in
>> > > > the group matches a query.
>> > > >
>> > > > Example:
>> > > > I have two documents indexed and both share the *groupId *property
>> that
>> > > > defines the grouping field.
>> > > >
>> > > > *{*
>> > > > *        "groupId": "223",*
>> > > > *        "modality": "Computed Tomography",*
>> > > > *        "anatomy": "Subcutaneous fat",*
>> > > > *        "pathology": "Metastasis",*
>> > > > *}*
>> > > >
>> > > > *{*
>> > > > *        "groupId": "223",*
>> > > > *        "modality": "Computed Tomography",*
>> > > > *        "anatomy": "Subcutaneous fat",*
>> > > > *        "pathology": "Normal",*
>> > > > *}*
>> > > >
>> > > > I need to retrieve both entries in the group when performing a query
>> > > like:
>> > > >
>> > > > *(pathology:Normal)*
>> > > > Is this possible in solr?
>> > > >
>> > > > Thanks!
>> > >
>> >
>>

Re: Find groups where at least one item matches a query

Posted by Cristian Popovici <cr...@visionsr.com>.
Doesn't seem to work - I'm doing a query like this and I get only one result

q=pathology:normal&group=true&group.field=groupId&*group.limit=2*

On Sun, Feb 5, 2017 at 7:20 PM, Nick Vasilyev <ni...@gmail.com>
wrote:

> Check out the group.limit argument.
>
> On Feb 5, 2017 12:10 PM, "Cristian Popovici" <cristi.popovici@visionsr.com
> >
> wrote:
>
> > Erick, thanks for you answer.
> >
> > Sorry - I forgot to mention that I do not know the group id when I
> perform
> > the query.
> > Grouping - I think - does not help for me as it filters out the documents
> > that do not meet the filter criteria.
> >
> > Example:
> > *q=pathology:Normal&group=true&group.field=groupId*  will miss out the
> > "pathology":
> > "Metastasis".
> >
> > I need to retrieve both documents in the same group even if only one
> meets
> > the search criteria.
> >
> > Thanks!
> >
> > On Sun, Feb 5, 2017 at 6:54 PM, Erick Erickson <er...@gmail.com>
> > wrote:
> >
> > > Isn't this just "&fq=groupId:223"?
> > >
> > > Or do you mean you need multiple _groups_? In which case you can use
> > > grouping, see:
> > > https://cwiki.apache.org/confluence/display/solr/
> > > Collapse+and+Expand+Results
> > > and/or
> > > https://cwiki.apache.org/confluence/display/solr/Result+Grouping
> > >
> > > but do note there are some limitations in distributed mode.
> > >
> > > Best,
> > > Erick
> > >
> > > On Sun, Feb 5, 2017 at 1:49 AM, Cristian Popovici
> > > <cr...@visionsr.com> wrote:
> > > > Hi all,
> > > >
> > > > I'm new to Solr and I need a bit of help.
> > > >
> > > > I have a structure of documents indexed in Solr that are grouped
> > together
> > > > by a property. I need to retrieve all groups where at least one entry
> > in
> > > > the group matches a query.
> > > >
> > > > Example:
> > > > I have two documents indexed and both share the *groupId *property
> that
> > > > defines the grouping field.
> > > >
> > > > *{*
> > > > *        "groupId": "223",*
> > > > *        "modality": "Computed Tomography",*
> > > > *        "anatomy": "Subcutaneous fat",*
> > > > *        "pathology": "Metastasis",*
> > > > *}*
> > > >
> > > > *{*
> > > > *        "groupId": "223",*
> > > > *        "modality": "Computed Tomography",*
> > > > *        "anatomy": "Subcutaneous fat",*
> > > > *        "pathology": "Normal",*
> > > > *}*
> > > >
> > > > I need to retrieve both entries in the group when performing a query
> > > like:
> > > >
> > > > *(pathology:Normal)*
> > > > Is this possible in solr?
> > > >
> > > > Thanks!
> > >
> >
>

Re: Find groups where at least one item matches a query

Posted by Nick Vasilyev <ni...@gmail.com>.
Check out the group.limit argument.

On Feb 5, 2017 12:10 PM, "Cristian Popovici" <cr...@visionsr.com>
wrote:

> Erick, thanks for you answer.
>
> Sorry - I forgot to mention that I do not know the group id when I perform
> the query.
> Grouping - I think - does not help for me as it filters out the documents
> that do not meet the filter criteria.
>
> Example:
> *q=pathology:Normal&group=true&group.field=groupId*  will miss out the
> "pathology":
> "Metastasis".
>
> I need to retrieve both documents in the same group even if only one meets
> the search criteria.
>
> Thanks!
>
> On Sun, Feb 5, 2017 at 6:54 PM, Erick Erickson <er...@gmail.com>
> wrote:
>
> > Isn't this just "&fq=groupId:223"?
> >
> > Or do you mean you need multiple _groups_? In which case you can use
> > grouping, see:
> > https://cwiki.apache.org/confluence/display/solr/
> > Collapse+and+Expand+Results
> > and/or
> > https://cwiki.apache.org/confluence/display/solr/Result+Grouping
> >
> > but do note there are some limitations in distributed mode.
> >
> > Best,
> > Erick
> >
> > On Sun, Feb 5, 2017 at 1:49 AM, Cristian Popovici
> > <cr...@visionsr.com> wrote:
> > > Hi all,
> > >
> > > I'm new to Solr and I need a bit of help.
> > >
> > > I have a structure of documents indexed in Solr that are grouped
> together
> > > by a property. I need to retrieve all groups where at least one entry
> in
> > > the group matches a query.
> > >
> > > Example:
> > > I have two documents indexed and both share the *groupId *property that
> > > defines the grouping field.
> > >
> > > *{*
> > > *        "groupId": "223",*
> > > *        "modality": "Computed Tomography",*
> > > *        "anatomy": "Subcutaneous fat",*
> > > *        "pathology": "Metastasis",*
> > > *}*
> > >
> > > *{*
> > > *        "groupId": "223",*
> > > *        "modality": "Computed Tomography",*
> > > *        "anatomy": "Subcutaneous fat",*
> > > *        "pathology": "Normal",*
> > > *}*
> > >
> > > I need to retrieve both entries in the group when performing a query
> > like:
> > >
> > > *(pathology:Normal)*
> > > Is this possible in solr?
> > >
> > > Thanks!
> >
>

Re: Find groups where at least one item matches a query

Posted by Cristian Popovici <cr...@visionsr.com>.
Erick, thanks for you answer.

Sorry - I forgot to mention that I do not know the group id when I perform
the query.
Grouping - I think - does not help for me as it filters out the documents
that do not meet the filter criteria.

Example:
*q=pathology:Normal&group=true&group.field=groupId*  will miss out the
"pathology":
"Metastasis".

I need to retrieve both documents in the same group even if only one meets
the search criteria.

Thanks!

On Sun, Feb 5, 2017 at 6:54 PM, Erick Erickson <er...@gmail.com>
wrote:

> Isn't this just "&fq=groupId:223"?
>
> Or do you mean you need multiple _groups_? In which case you can use
> grouping, see:
> https://cwiki.apache.org/confluence/display/solr/
> Collapse+and+Expand+Results
> and/or
> https://cwiki.apache.org/confluence/display/solr/Result+Grouping
>
> but do note there are some limitations in distributed mode.
>
> Best,
> Erick
>
> On Sun, Feb 5, 2017 at 1:49 AM, Cristian Popovici
> <cr...@visionsr.com> wrote:
> > Hi all,
> >
> > I'm new to Solr and I need a bit of help.
> >
> > I have a structure of documents indexed in Solr that are grouped together
> > by a property. I need to retrieve all groups where at least one entry in
> > the group matches a query.
> >
> > Example:
> > I have two documents indexed and both share the *groupId *property that
> > defines the grouping field.
> >
> > *{*
> > *        "groupId": "223",*
> > *        "modality": "Computed Tomography",*
> > *        "anatomy": "Subcutaneous fat",*
> > *        "pathology": "Metastasis",*
> > *}*
> >
> > *{*
> > *        "groupId": "223",*
> > *        "modality": "Computed Tomography",*
> > *        "anatomy": "Subcutaneous fat",*
> > *        "pathology": "Normal",*
> > *}*
> >
> > I need to retrieve both entries in the group when performing a query
> like:
> >
> > *(pathology:Normal)*
> > Is this possible in solr?
> >
> > Thanks!
>

Re: Find groups where at least one item matches a query

Posted by Erick Erickson <er...@gmail.com>.
Isn't this just "&fq=groupId:223"?

Or do you mean you need multiple _groups_? In which case you can use
grouping, see:
https://cwiki.apache.org/confluence/display/solr/Collapse+and+Expand+Results
and/or
https://cwiki.apache.org/confluence/display/solr/Result+Grouping

but do note there are some limitations in distributed mode.

Best,
Erick

On Sun, Feb 5, 2017 at 1:49 AM, Cristian Popovici
<cr...@visionsr.com> wrote:
> Hi all,
>
> I'm new to Solr and I need a bit of help.
>
> I have a structure of documents indexed in Solr that are grouped together
> by a property. I need to retrieve all groups where at least one entry in
> the group matches a query.
>
> Example:
> I have two documents indexed and both share the *groupId *property that
> defines the grouping field.
>
> *{*
> *        "groupId": "223",*
> *        "modality": "Computed Tomography",*
> *        "anatomy": "Subcutaneous fat",*
> *        "pathology": "Metastasis",*
> *}*
>
> *{*
> *        "groupId": "223",*
> *        "modality": "Computed Tomography",*
> *        "anatomy": "Subcutaneous fat",*
> *        "pathology": "Normal",*
> *}*
>
> I need to retrieve both entries in the group when performing a query like:
>
> *(pathology:Normal)*
> Is this possible in solr?
>
> Thanks!