Using Field Collapsing and Filter Query to implement JOIN

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Using Field Collapsing and Filter Query to implement JOIN

Lester Scofield
Hello solr people,
    I'm very new to solr to please forgive any misunderstanding on my part.
I am hoping to do a  JOIN across documents.

Let me start with the 4 documents:

<doc>
  <field name="type">part1</field>
  <field name="key">ABC</field>
  <field name="foo">this is a test</field>
</doc>
<doc>
   <field name="type">part2</field>
   <field name="key">ABC</field>
   <field name="bar">of a fake JOIN</field>
</doc>
<doc>
  <field name="type">part1</field>
  <field name="key">XYZ</field>
  <field name="foo">this is a test</field>
</doc>
<doc>
   <field name="type">part2</field>
   <field name="key">XYZ</field>
   <field name="bar">of a mismatch</field>
</doc>



If I wanted to form a fake query that was something like:
(+type:part1 AND +foo:test) AND (+type:part2 AND +bar:join) AND (JOIN-ON:key)

I could first change this into:
(+type:part1 AND +foo:test) OR (+type:part2 AND +bar:join)
and field collapse on field "key"

I would then use Filter Query to remove any hits that did not collapse
into 2 fields with something like:
(+collapse:2)
In this way I would exclude the match on the 3rd doc above.

I know there is a problem with being able to get at the number of
collapsed items in the result set like this, but maybe an updated
patch to "Field Collapse" could be made.
Something that lets you name a field that will house the number of
documents collapsed.

I am not sure how field collapse would work with Filter Query, is
there a problem here?

I'm also not sure if it would be best to use Filter Query or the other
filter that happens after the main query (I get the names confused).

So what do you all think?  I hope this could at least spark an idea on
how this could really happen.

Thank you all,
Lester