lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jitender ahuja" <ajiten...@aalayance.com>
Subject Re: Doing a join?
Date Sat, 24 Apr 2004 12:47:52 GMT
Hi,
   I feel by different files u mean two different sub directories under a
common folder(i.e. directory).
    Now, one stores 3 fields and another one stores 2 fields.
    Also, the class_Id or Class_Name(file 1) and the Student_Id fields(file
2) should be indexed and
    stored in the index.
    You need to have your own code for implementing the same, that will
perform the search.
    The code snippet below, I feel if included in ur own searcher code would
provide results on the
    command line.
    Also, I have not tested it but in case of problem, pl. send me a small
sample database of the two tables
    to be indexed( and not the index files) or something similar one.

Regards,
Jitender

code:
========
String searchStr=null;
ArrayList results = new ArrayList();
ArrayList results1 = new ArrayList();
Searcher indexSrch = new IndexSearcher("file1");//"file1" is the file that
stores the 3 fields
Analyzer analyzer = new StandardAnalyzer();
Query query = QueryParser.parse(searchStr, "Class_Id", analyzer);
Hits hits = indexSrch.search(query);
for( int i=0; i<hits.length(); i++)
 {
   Document doc = hits.doc(i);
   String id = doc.get("Student_Id");// retrieves the Student's Id
   results.add(id);
 }

// need to feed the "results" contents to the query1 as "searchStr1"
Searcher indexSrch1 = new IndexSearcher("file2");//"file2" is the file that
stores 2 fields

if (hits.length!=0)
{
for (int j = 0; j<results.size(); String searchStr1= results.get(j))
{
Query query1= QueryParser.parse(searchStr1, "Student_Id", analyzer);
Hits hits1 = indexSrch1.search(query1);
for( int k=0; k<hits1.length(); k++)
 {
 Document doc = hits1.doc(0);
 String Student_name = doc.get("Student_Name");
 results1.add(Student_name);
 }
 }
 }
----- Original Message ----- 
From: "Rob Jose" <rjose@surewest.net>
To: "Lucene Users List" <lucene-user@jakarta.apache.org>
Sent: Thursday, April 22, 2004 11:56 PM
Subject: Doing a join?


> Is it possible to do a join on two fields when searching a Lucene Index.
> For example, I have an index of documents that have a "StudentName" and a
> "StudentId" field and another document that has "ClassId", "ClassName" and
> "StudentId".  I want to do a search on "ClassId" or "ClassName" and get a
> list of "StudentName".  Both of these documents are in one index, but are
> loaded from seperate files, so I can't join at creation time.  Any help is
> greatly appreciated.
>
> Rob
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
>


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


Mime
View raw message