You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Mohammad Norouzi <mn...@gmail.com> on 2007/03/26 08:17:58 UTC

how to search over another search

hi
I have two separated index but there are some fields that are common between
them. now I want to search from one index and then apply the result to the
second one. what solution do you suggest?
what happens on fields? I mean the first document has some fields that are
not present in the second one so I need the final document has all the
fields of both indexes.

thanks


-- 
Regards,
Mohammad

Re: how to search over another search

Posted by Mohammad Norouzi <mn...@gmail.com>.
Hi Erick,

>>Why not combine the indexes? That would be the "lucene way"...

I combined them by joining tables but it gets very very large and ResaltSet
failed to retrieve the fields!!!

On 3/26/07, Erick Erickson <er...@gmail.com> wrote:
>
> The short form is no. Lucene is emphatically NOT a relational database.
> Of course, you could take the results of the first search, collect the IDs
> and query the second, but for large sets this may not be practical
>
> Why not combine the indexes? That would be the "lucene way"...
>
> There has been extensive discussion of embedding Lucene in a DB,
> but I can't remember who. Search the archive for Oracle and you'll find
> an extensive discussion....
>
> Best
> Erick
>
>
> On 3/26/07, Mohammad Norouzi <mn...@gmail.com> wrote:
> >
> > I mean when I get result from the first index, find the common records
> > from
> > the second index depending on first result.
> > something like relation between two database tables, relation by primary
> > key
> >
> > index1:
> > id           name                 somefield1
> > 1             jack                   value1
> > 2            Michael              value2
> > 3             Sara                  value3
> > 4            Joseph                value4
> > ...
> >
> >
> > index2:
> > id              field1              field2              field3
> > 2               fval1-1            fval2-1             fval3-1
> > 4               fval1-2            fval2-2             fval3-2
> > ...
> >
> > now a user puts query : name:Michael
> >
> > I should return the result wrapped in following document:
> > document:
> > id           name       somefield1
> field1      field2        field3
> >
> >
> ------------------------------------------------------------------------------------------
> > 2            Michael    value2             fval1-1    fval2-1
> > fval3-1
> >
> >
> >
> > On 3/26/07, jafarim <ja...@gmail.com> wrote:
> > >
> > > what do you mean by "applying the result to the second one"?
> > >
> > > On 3/26/07, Mohammad Norouzi <mn...@gmail.com> wrote:
> > > >
> > > > hi
> > > > I have two separated index but there are some fields that are common
> > > > between
> > > > them. now I want to search from one index and then apply the result
> to
> > > the
> > > > second one. what solution do you suggest?
> > > > what happens on fields? I mean the first document has some fields
> that
> > > are
> > > > not present in the second one so I need the final document has all
> the
> > > > fields of both indexes.
> > > >
> > > > thanks
> > > >
> > > >
> > > > --
> > > > Regards,
> > > > Mohammad
> > > >
> > >
> >
> >
> >
> > --
> > Regards,
> > Mohammad
> >
>



-- 
Regards,
Mohammad

Re: how to search over another search

Posted by Erick Erickson <er...@gmail.com>.
The short form is no. Lucene is emphatically NOT a relational database.
Of course, you could take the results of the first search, collect the IDs
and query the second, but for large sets this may not be practical

Why not combine the indexes? That would be the "lucene way"...

There has been extensive discussion of embedding Lucene in a DB,
but I can't remember who. Search the archive for Oracle and you'll find
an extensive discussion....

Best
Erick


On 3/26/07, Mohammad Norouzi <mn...@gmail.com> wrote:
>
> I mean when I get result from the first index, find the common records
> from
> the second index depending on first result.
> something like relation between two database tables, relation by primary
> key
>
> index1:
> id           name                 somefield1
> 1             jack                   value1
> 2            Michael              value2
> 3             Sara                  value3
> 4            Joseph                value4
> ...
>
>
> index2:
> id              field1              field2              field3
> 2               fval1-1            fval2-1             fval3-1
> 4               fval1-2            fval2-2             fval3-2
> ...
>
> now a user puts query : name:Michael
>
> I should return the result wrapped in following document:
> document:
> id           name       somefield1       field1      field2        field3
>
> ------------------------------------------------------------------------------------------
> 2            Michael    value2             fval1-1    fval2-1
> fval3-1
>
>
>
> On 3/26/07, jafarim <ja...@gmail.com> wrote:
> >
> > what do you mean by "applying the result to the second one"?
> >
> > On 3/26/07, Mohammad Norouzi <mn...@gmail.com> wrote:
> > >
> > > hi
> > > I have two separated index but there are some fields that are common
> > > between
> > > them. now I want to search from one index and then apply the result to
> > the
> > > second one. what solution do you suggest?
> > > what happens on fields? I mean the first document has some fields that
> > are
> > > not present in the second one so I need the final document has all the
> > > fields of both indexes.
> > >
> > > thanks
> > >
> > >
> > > --
> > > Regards,
> > > Mohammad
> > >
> >
>
>
>
> --
> Regards,
> Mohammad
>

Re: how to search over another search

Posted by Mohammad Norouzi <mn...@gmail.com>.
I mean when I get result from the first index, find the common records from
the second index depending on first result.
something like relation between two database tables, relation by primary key

index1:
id           name                 somefield1
1             jack                   value1
2            Michael              value2
3             Sara                  value3
4            Joseph                value4
...


index2:
id              field1              field2              field3
2               fval1-1            fval2-1             fval3-1
4               fval1-2            fval2-2             fval3-2
...

now a user puts query : name:Michael

I should return the result wrapped in following document:
document:
id           name       somefield1       field1      field2        field3
------------------------------------------------------------------------------------------
2            Michael    value2             fval1-1    fval2-1       fval3-1



On 3/26/07, jafarim <ja...@gmail.com> wrote:
>
> what do you mean by "applying the result to the second one"?
>
> On 3/26/07, Mohammad Norouzi <mn...@gmail.com> wrote:
> >
> > hi
> > I have two separated index but there are some fields that are common
> > between
> > them. now I want to search from one index and then apply the result to
> the
> > second one. what solution do you suggest?
> > what happens on fields? I mean the first document has some fields that
> are
> > not present in the second one so I need the final document has all the
> > fields of both indexes.
> >
> > thanks
> >
> >
> > --
> > Regards,
> > Mohammad
> >
>



-- 
Regards,
Mohammad

Re: how to search over another search

Posted by jafarim <ja...@gmail.com>.
what do you mean by "applying the result to the second one"?

On 3/26/07, Mohammad Norouzi <mn...@gmail.com> wrote:
>
> hi
> I have two separated index but there are some fields that are common
> between
> them. now I want to search from one index and then apply the result to the
> second one. what solution do you suggest?
> what happens on fields? I mean the first document has some fields that are
> not present in the second one so I need the final document has all the
> fields of both indexes.
>
> thanks
>
>
> --
> Regards,
> Mohammad
>

Re: how to search over another search

Posted by Mohammad Norouzi <mn...@gmail.com>.
sorry I cant comprehend, so why we should use two separate index? we can
merge it in one index file?

On 3/27/07, Steven Rowe <sa...@syr.edu> wrote:
>
> Mohammad Norouzi wrote:
> > Steven,
> > what this means:
> > "Each index added must have the same number of documents, but
> > typically each contains different fields. Each document contains the
> > union of the fields of all documents with the same document number.
> > When searching, matches for a query term are from the first index
> > added that has the field."
> >
> > if I have say, 100 documents (records) in index, I should have exactly
> 100
> > documents in index2. Am I right?
>
> Yes.  The other requirement is that the documents must be added in
> exactly the same order to both indexes.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
Regards,
Mohammad

Re: how to search over another search

Posted by Steven Rowe <sa...@syr.edu>.
Mohammad Norouzi wrote:
> Steven,
> what this means:
> "Each index added must have the same number of documents, but
> typically each contains different fields. Each document contains the
> union of the fields of all documents with the same document number.
> When searching, matches for a query term are from the first index
> added that has the field."
> 
> if I have say, 100 documents (records) in index, I should have exactly 100
> documents in index2. Am I right?

Yes.  The other requirement is that the documents must be added in
exactly the same order to both indexes.


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


Re: how to search over another search

Posted by Mohammad Norouzi <mn...@gmail.com>.
Steven,
what this means:
"Each index added must have the same number of documents, but typically each
contains different fields. Each document contains the union of the fields of
all documents with the same document number. When searching, matches for a
query term are from the first index added that has the field."

if I have say, 100 documents (records) in index, I should have exactly 100
documents in index2. Am I right?

Erick,
is following title, the discussion you mentioned about embedding Lucene in a
DB?
"Lucene vs. in-DB-full-text-searching"


-- 
Regards,
Mohammad

Re: how to search over another search

Posted by Steven Rowe <sa...@syr.edu>.
Oops, sorry for the confusion, I was thinking of ParallelReader, first
available in Lucene-Java release 1.9:

<http://lucene.apache.org/java/docs/api/org/apache/lucene/index/ParallelReader.html>

-----
An IndexReader which reads multiple, parallel indexes. Each index added
must have the same number of documents, but typically each contains
different fields. Each document contains the union of the fields of all
documents with the same document number. When searching, matches for a
query term are from the first index added that has the field.

This is useful, e.g., with collections that have large fields which
change rarely and small fields that change more frequently. The smaller
fields may be re-indexed in a new index and both indexes may be searched
together.

Warning: It is up to you to make sure all indexes are created and
modified the same way. For example, if you add documents to one index,
you need to add the same documents in the same order to the other
indexes. Failure to do so will result in undefined behavior.
-----

Steve


Steven Rowe wrote:
> Hi Mohammad,
> 
> Have you looked at MultiSearcher?
> 
> <http://lucene.apache.org/java/docs/api/org/apache/lucene/search/MultiSearcher.html>
> 
> Section 5.6 of Lucene in Action covers its use.
> 
> Steve
> 
> Mohammad Norouzi wrote:
>> hi
>> I have two separated index but there are some fields that are common
>> between
>> them. now I want to search from one index and then apply the result to the
>> second one. what solution do you suggest?
>> what happens on fields? I mean the first document has some fields that are
>> not present in the second one so I need the final document has all the
>> fields of both indexes.
>>
>> thanks
> 
> 
> ---------------------------------------------------------------------
> 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


Re: how to search over another search

Posted by Steven Rowe <sa...@syr.edu>.
Hi Mohammad,

Have you looked at MultiSearcher?

<http://lucene.apache.org/java/docs/api/org/apache/lucene/search/MultiSearcher.html>

Section 5.6 of Lucene in Action covers its use.

Steve

Mohammad Norouzi wrote:
> hi
> I have two separated index but there are some fields that are common
> between
> them. now I want to search from one index and then apply the result to the
> second one. what solution do you suggest?
> what happens on fields? I mean the first document has some fields that are
> not present in the second one so I need the final document has all the
> fields of both indexes.
> 
> thanks


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