When you create a query to the searcher you can specify which field to search on for example:
Query query = queryParser.parse(searchTerm); QueryParser is constructed like this: QueryParser queryParser = new AnalyzingQueryParser<http://lucene.apache.org/java/2_4_0/api/org/apache/lucene/queryParser/analyzing/AnalyzingQueryParser.html#AnalyzingQueryParser(java.lang.String,%20org.apache.lucene.analysis.Analyzer)>("name",new StandardAnalyzer()); Pass the query to the IndexSearcher and you get hits. From the hits you can get the documents and from each matching doucment you can get the phone number field (if you store the number in the index). HTH On Sun, Mar 15, 2009 at 1:32 PM, Seid Mohammed <seidy...@gmail.com> wrote: > dear Erick, that one I have tried the very begining on playing lucene. > I know how to create documents, but my question is I want to create > documents with fields such as person-name and phone-number and so on. > while searching, i will submit a person name so that it will return me > the phone number of that person. > > hope you get my problem > > Thanks a lot > > Seid M > > On 3/15/09, Erick Erickson <erickerick...@gmail.com> wrote: > > Have you tried working through the getting started guide at > > http://lucene.apache.org/java/2_4_1/gettingstarted.html? That > > should give you a good idea of how to create a document in Lucene. > > > > > > Best > > Erick > > > > On Sun, Mar 15, 2009 at 8:49 AM, Seid Mohammed <seidy...@gmail.com> > wrote: > > > >> that is exactly my question > >> how can I do that? > >> > >> thanks a lot > >> Seid M > >> > >> On 3/15/09, Amin Mohammed-Coleman <ami...@gmail.com> wrote: > >> > Why don't you create a Lucene document that represents a Person and > then > >> > index the fields name, age, phone number, etc. Search on the name and > >> then > >> > get the corresponding phone number from the search. > >> > Cheers > >> > Amin > >> > > >> > On Sun, Mar 15, 2009 at 10:56 AM, Seid Mohammed <seidy...@gmail.com> > >> wrote: > >> > > >> >> I want to Index Person_Name and associated phone number. > >> >> Example: Abebe ===>+2519112332 > >> >> later, When I search for Abebe, it should display +2519112332 > >> >> any hint > >> >> > >> >> seid M > >> >> > >> >> -- > >> >> "RABI ZIDNI ILMA" > >> >> > >> >> --------------------------------------------------------------------- > >> >> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > >> >> For additional commands, e-mail: java-user-h...@lucene.apache.org > >> >> > >> >> > >> > > >> > >> > >> -- > >> "RABI ZIDNI ILMA" > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > >> For additional commands, e-mail: java-user-h...@lucene.apache.org > >> > >> > > > > > -- > "RABI ZIDNI ILMA" > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > >