hipjim
hipjim

Reputation: 128

Solr: find groups containing a value

I have a structure of documents indexed in Solr that are grouped together by a property. Let's say I have a group consisting of three documents: A -> B -> C

I want to performa query by a property value V that will return the whole group whether A or B or C contain the value V. For example - the query will return my whole group (A,B,C) if B contains the value V.

Is this possible in solr?

Thanks!

Upvotes: 0

Views: 62

Answers (1)

Persimmonium
Persimmonium

Reputation: 15791

If I understand correctly, yes, this possible. You can use Graph query parser to do this:

  1. you index your docs with the right info on how docs are linked to each other in some fields (see sample in the docs).
  2. then, you query like this:

    q={!graph+from=in_edge+to=out_edge}id:A

where id:A is the query to get the starting set of docs, and the {!graph ...} is to get all docs reachable from the starting set.

Some caveats:

  1. works only in standalone solr or single Solrcloud shard (though some graph features are available also in Streaming expressions, those would work across all shards, but have less features for now)
  2. depending on how the graph of docs you want to reach looks like (and how you index the edge info), works case you might need to run two queries, one to get the docs 'from' the starting set and another to get the docs 'to' the starting set, for example.

Upvotes: 1

Related Questions