join in lucene

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

join in lucene

Cristian Lorenzetto
I want realize multiple joins in lucene.
Considering the complexy of joining i want i will skip index join.

first strategy :
Query-time joins

String fromField = "from"; // Name of the from field
  boolean multipleValuesPerDocument = false; // Set only yo true in
the case when your fromField has multiple values per document in your
index
  String toField = "to"; // Name of the to field
  ScoreMode scoreMode = ScoreMode.Max // Defines how the scores are
translated into the other side of the join.
  Query fromQuery = new TermQuery(new Term("content", searchTerm)); //
Query executed to collect from values to join to the to values

  Query joinQuery = JoinUtil.createJoinQuery(fromField,
multipleValuesPerDocument, toField, fromQuery, fromSearcher,
scoreMode);
  TopDocs topDocs = toSearcher.search(joinQuery, 10); // Note:
toSearcher can be the same as the fromSearcher
  // Render topDocs...

*First question is: *

*it possible to use joinedQuery in nested way(if i have 2 joins to 2
different entities for example)? *
*main query -> nested inside first join -> nested in the second join,...*


Query-custom joins
I could realize a mini class Loader  making joins:
 1) every entity is a different class
 2) by reflection if the getter is class ==entity .... Loader load document
with the key saved in parent object.


*second question:*
*this solution is essentially similar to how it works the query times or
not (so similar performance)?*
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: join in lucene

Mikhail Khludnev-2
>
> *it possible to use joinedQuery in nested way(if i have 2 joins to 2
> different entities for example)? *
> *main query -> nested inside first join -> nested in the second join,...*


I don't see any reasons why it couldn't work in this manner. but it just
usually slow.


On Thu, Mar 16, 2017 at 8:59 PM, Cristian Lorenzetto <
[hidden email]> wrote:

> I want realize multiple joins in lucene.
> Considering the complexy of joining i want i will skip index join.
>
> first strategy :
> Query-time joins
>
> String fromField = "from"; // Name of the from field
>   boolean multipleValuesPerDocument = false; // Set only yo true in
> the case when your fromField has multiple values per document in your
> index
>   String toField = "to"; // Name of the to field
>   ScoreMode scoreMode = ScoreMode.Max // Defines how the scores are
> translated into the other side of the join.
>   Query fromQuery = new TermQuery(new Term("content", searchTerm)); //
> Query executed to collect from values to join to the to values
>
>   Query joinQuery = JoinUtil.createJoinQuery(fromField,
> multipleValuesPerDocument, toField, fromQuery, fromSearcher,
> scoreMode);
>   TopDocs topDocs = toSearcher.search(joinQuery, 10); // Note:
> toSearcher can be the same as the fromSearcher
>   // Render topDocs...
>
> *First question is: *
>
> *it possible to use joinedQuery in nested way(if i have 2 joins to 2
> different entities for example)? *
> *main query -> nested inside first join -> nested in the second join,...*
>
>
> Query-custom joins
> I could realize a mini class Loader  making joins:
>  1) every entity is a different class
>  2) by reflection if the getter is class ==entity .... Loader load document
> with the key saved in parent object.
>
>
> *second question:*
> *this solution is essentially similar to how it works the query times or
> not (so similar performance)?*
>



--
Sincerely yours
Mikhail Khludnev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: join in lucene

Cristian Lorenzetto
ok but the second solution has same performance or not?

pratically query-times join work making nested query:

execute first query
then for every row it execute the corrisponding row in the secondat table
using foreign key and primary key ?

2017-03-16 19:47 GMT+01:00 Mikhail Khludnev <[hidden email]>:

> >
> > *it possible to use joinedQuery in nested way(if i have 2 joins to 2
> > different entities for example)? *
> > *main query -> nested inside first join -> nested in the second join,...*
>
>
> I don't see any reasons why it couldn't work in this manner. but it just
> usually slow.
>
>
> On Thu, Mar 16, 2017 at 8:59 PM, Cristian Lorenzetto <
> [hidden email]> wrote:
>
> > I want realize multiple joins in lucene.
> > Considering the complexy of joining i want i will skip index join.
> >
> > first strategy :
> > Query-time joins
> >
> > String fromField = "from"; // Name of the from field
> >   boolean multipleValuesPerDocument = false; // Set only yo true in
> > the case when your fromField has multiple values per document in your
> > index
> >   String toField = "to"; // Name of the to field
> >   ScoreMode scoreMode = ScoreMode.Max // Defines how the scores are
> > translated into the other side of the join.
> >   Query fromQuery = new TermQuery(new Term("content", searchTerm)); //
> > Query executed to collect from values to join to the to values
> >
> >   Query joinQuery = JoinUtil.createJoinQuery(fromField,
> > multipleValuesPerDocument, toField, fromQuery, fromSearcher,
> > scoreMode);
> >   TopDocs topDocs = toSearcher.search(joinQuery, 10); // Note:
> > toSearcher can be the same as the fromSearcher
> >   // Render topDocs...
> >
> > *First question is: *
> >
> > *it possible to use joinedQuery in nested way(if i have 2 joins to 2
> > different entities for example)? *
> > *main query -> nested inside first join -> nested in the second join,...*
> >
> >
> > Query-custom joins
> > I could realize a mini class Loader  making joins:
> >  1) every entity is a different class
> >  2) by reflection if the getter is class ==entity .... Loader load
> document
> > with the key saved in parent object.
> >
> >
> > *second question:*
> > *this solution is essentially similar to how it works the query times or
> > not (so similar performance)?*
> >
>
>
>
> --
> Sincerely yours
> Mikhail Khludnev
>
Loading...