lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Newton <glen.new...@gmail.com>
Subject Re: Question about JoinUtil
Date Wed, 17 Dec 2014 23:41:20 GMT
Hi Gregory,

Thanks for your reply. In reading it, I realized that one side of my
relational join wasn't that large, and I could bring it in as a couple
of fields to the main document without any penalty, so my need to join
two different document types then goes away.

Thanks!  :-)
Glen



On Tue, Dec 16, 2014 at 7:49 PM, Gregory Dearing <gregdearing@gmail.com> wrote:
> Glen,
>
> Lucene isn't relational at heart and may not be the right tool for
> what you're trying to accomplish. Note that JoinQuery doesn't join
> 'left' and 'right' answers; rather it transforms a 'left' answerset
> into a 'right' answerset.
>
> JoinQuery is able to perform this transformation with a single extra
> search, which wouldn't be possible if it accepted a 'toQuery'
> argument.
>
>
> That being said, here are some suggestions...
>
> 1. If all you really need is data from the 'right' set of answers (the
> joined TO set), then you can just add more queries to perform
> right-hand filtering.
>
>    createJoinQuery(...) AND TermQuery("country", "CA*")
>
> Note that 'left.name' in your SQL example is no longer available.
>
> 2. If you really need to filter both sides, and you need to return
> data from both sides, it probably requires some programming.  In
> pseudo-code...
>
>   leftAnswerSet = searcher.search(fromQuery)
>
>   foreach leftAnswer in leftAnswerSet {
>     rightAnswers = searcher.search(leftAnswer AND TermQuery("country", "CA*"))
>     results.add([leftAnswer, rightAnswers])
>   }
>
> This is obviously not very efficient, but I think it probably
> represents what JoinQuery would look like if it allowed a 'toQuery'
> capability and returned data from both sides of the join.
>
> 3. If you can denormalize your data into hierarchies, then you could
> use index-time joining (BlockJoin) for better performance and easier
> collecting of your grouped data.  This is really limiting if your
> relationships are truly many to many.
>
> Hope that helps,
> Greg
>
>
> On Tue, Dec 16, 2014 at 10:46 AM, Glen Newton <glen.newton@gmail.com> wrote:
>> Anyone?
>>
>> On Thu, Dec 11, 2014 at 2:53 PM, Glen Newton <glen.newton@gmail.com> wrote:
>>> Is there any reason JoinUtil (below) does not have a 'Query toQuery'
>>> available? I was wanting to filter on the 'to' side as well. I feel I
>>> am missing something here.
>>>
>>> To make sure this is not an XY problem, here is my use case:
>>>
>>> I have a many-to-many relationship. The left, join, and right 'table'
>>> objects are all indexed in the same lucene index, with a field 'type'
>>> to distinguish them.
>>>
>>> I need to do something like this:
>>> select left.name, right.country from left, join, right where
>>> left.type="fooType" and right.type="barType" and join.leftId=left.id
>>> and join.rightId=right.id and left.name="Fred*" and
>>> right.country="Ca*"
>>>
>>> Is JoinUtil the way to go?
>>> Or should I roll my own?
>>>    Or am I indexing/using-Lucene incorrectly, thinking relational when
>>> a different way to index or query would be better in an idiomatic
>>> Lucene manner?  :-)
>>>
>>>
>>> Thanks,
>>> Glen
>>>
>>> https://lucene.apache.org/core/4_10_2/join/org/apache/lucene/search/join/JoinUtil.html
>>>
>>> public static Query createJoinQuery(String fromField,
>>>                     boolean multipleValuesPerDocument,
>>>                     String toField,
>>>                     Query fromQuery,
>>>                     IndexSearcher fromSearcher,
>>>                     ScoreMode scoreMode)
>>>                              throws IOException
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message