You don't use any method signature in Lucene. Remember Lucene is a search engine. You create a proper query.
So your query will be something like this: Query query = QueryParser.parse("creator:\"Elizabeth Castro\"", "creator", new StandardAnalyzer()); indexSearcher.search(query); There if you want more "properties" and "values" you can have it by having it more in the search quer. IE: creator:"Victor Hugo" AND title:"Les Miserables" This will return you exactly 1 hit. HTH, /victor ----- Original Message ----- From: "Caroline Jen" <[EMAIL PROTECTED]> To: "Lucene Users List" <[EMAIL PROTECTED]> Sent: Thursday, November 06, 2003 4:52 PM Subject: Re: Rephrase My Question - How To Search Database With More Than One Pair of Property/Value as Parameters Using Lucene? > Hi, Victor: > > Thank you very much for your explanation of Lucene. I > think you understand what kind of search that I expect > Lucene to do. > > I have data tables created in the MySQL database. > > creator title category > > Elizabeth Castro J2EE computer > science > Isobelle Carmody Obernewtyn fiction > Victor Hugo Les Miserables literature > ... > ... > ... > > All records are indexed using an IndexWriter (see the > code at the end of this message). > > I have a sample program that takes care of the search > based on "one single pair of property and value" in > the database. For example, visitors of the web site > can retrieve all articles written by Elizabeth Castro. > "creator" is the property and "Elizabeth Castro" is > the value and they constitute one single pair of > property and value. The method signature of the > search is: > > findByProperty(this,property,value); > > What is the method signature in Lucene if I want to > search the database based on "two pairs of property > and value"? For example, I want to retrieve all > articles written by Elizabeth Castro in the "computer > science" category? > > Am I on the right track? Does my question make sense? > > -Caroline > > ==================================================== > public static final void index ( > Integer article, > Timestamp contributed, > String contributor, > String creator, > String title, > String journal_category, > String content, > IndexWriter writer) throws > ResourceException { > > try { > > Document document = new Document(); > > > document.add(Field.Keyword(Tokens.ARTICLE, > article.toString())); > > document.add(Field.Text(Tokens.TITLE, > Engine.blankNull(title))); > > > document.add(Field.Text(Tokens.CONTRIBUTED_DISPLAY, > > Engine.blankNull(contributed.toString()))); > > > document.add(Field.UnStored(Tokens.CONTRIBUTOR, > Engine.blankNull(contributor))); > > > document.add(Field.UnStored(Tokens.CREATOR, > Engine.blankNull(creator))); > > > document.add(Field.UnStored(Tokens.JOURNAL_CATEGORY, > > Engine.blankNull(journal_category))); > > > document.add(Field.UnStored(Tokens.CONTENT, > Engine.blankNull(content))); > > writer.addDocument(document); > > } > catch (IOException e) { > throw new ResourceException(e); > } > > } // end index > > public static final void index ( > boolean create, > Integer article, > Timestamp contributed, > String contributor, > String creator, > String title, > String journal_category, > String content) throws ResourceException { > > IndexWriter writer = null; > > try { > // delete old index entry if this is an > update > if (!create) indexDeleteArticle(article); > // get the writer, index the entry, > optimize ... > writer = Engine.getIndexWriter(false); > index( > article, > contributed, > contributor, > creator, > title, > journal_category, > content, > writer); > writer.optimize(); > } > catch (IOException e) { > throw new ResourceException(e); > } > // and close the writer > finally { > try { > if (writer!=null) writer.close(); > } > catch (IOException e) { > // do nothing > } > } > } // end index > > > --- Victor Hadianto <[EMAIL PROTECTED]> wrote: > > Lucene is a metadata based search engine. When you > > create 'Lucene document' > > you create the metadata with the associated value. > > > > For example > > > > Document doc = new Document(); > > doc.Add(Field.Text("author", "Isobelle Carmody ")); > > doc.Add(Field.Text("category", "fiction")); > > doc.Add(Field.Text("title", "Obernewtyn")); > > > > And thus when you search Lucene you search based on > > the fields. For example > > if you want to search the author carmody within the > > category fiction you > > would do: > > > > author:carmody AND category:fiction > > > > This will return all documents that has the metadata > > author:carmody within > > the category:fiction (or the other way around > > doesn't really matter). > > > > HTH, > > > > /victor > > > > > > > > ----- Original Message ----- > > From: "Caroline Jen" <[EMAIL PROTECTED]> > > To: "Lucene Users List" > > <[EMAIL PROTECTED]> > > Sent: Tuesday, November 04, 2003 2:26 PM > > Subject: Re: Rephrase My Question - How To Search > > Database With More Than > > One Pair of Property/Value as Parameters Using > > Lucene? > > > > > > > Thank you for your reply. I am afraid that I was > > not > > > clear enough about what I have been doing. > > > > > > All the articles in the database can be searched > > by > > > either author; or title; or content; or id; or > > > category. > > > > > > If visitor of the web site selects to search by > > author > > > (then, "author" is highlighted in the drop-down > > list), > > > the visitor must fill out the name of the author > > in > > > the text field. As such, author and the name of > > the > > > author is a property/value pair. "author" > > corresponds > > > to property, and the name of the author provided > > > corresponds to value. This part of the search is > > > OKay. I have handled it. > > > > > > My problem is that there is one more dimension > > > involed. The propery of this additional dimension > > is > > > "category" and the value of this dimension is > > supplied > > > by the application developer; for example, > > HISTORY. > > > > > > My question is how to search articles by author > > (or > > > title) with his/her name (or the title of the > > article) > > > provide within the field name in the database that > > is > > > "category" and its value is HISTORY? > > > > > > How do I use analyser(), getHits(), getQuery() in > > > Lucene in this kind of situation? It is really > > the > > > first time I use Lucene. > > > > > > Thanks a lot in advance. > > > > > > -Caroline > > > --- Victor Hadianto <[EMAIL PROTECTED]> wrote: > > > > Something like this? > > > > > > > > Query query = QueryParser.parse("\"Victor Hugo\" > > > > title:Miserables", > > > > "author", new StandardAnalyser(); > > > > > > > > or > > > > > > > > Query query = QueryParser.parse("\"Victor Hugo\" > > > > title:Miserables > > > > category:history", "author", new > > StandardAnalyser(); > > > > > > > > /victor > > > > > > > > ----- Original Message ----- > > > > From: "Caroline Jen" <[EMAIL PROTECTED]> > > > > To: <[EMAIL PROTECTED]> > > > > Sent: Tuesday, November 04, 2003 1:52 PM > > > > Subject: Rephrase My Question - How To Search > > > > Database With More Than One > > > > Pair of Property/Value as Parameters Using > > Lucene? > > > > > > > > > > > > > I raised the question two days ago. My > > question > > > > was > > > > > too specific to the application that I have > > been > > > > > working on. I have decided to re-phrase my > > > > question. > > > > > > > > > > People say that Lucene is very flexible. > > I > > > > > wonder if there is a method signature that > > would > > > > be > > > > > suitable to my needs. Or there are way to go > > > > about > > > > > it. > > > > > > > > > > I am using lucene as the searching enging > > to > > > > look > > > > > for articles that are stores in the database. > > > > > It is OKay to search articles in the database > > > > using > > > > > "only one" pair of property/value as > > parameters in > > > > a > > > > > method; for example: > > > > > > > > > > ********Property***************Value > > > > > > > > > > *********author************Victor Hugo or > > ..... > > > > > *********title*************Les Miserables or > > ..... > > > > > ********content***************whatever ..... > > > > > **********id*********************168 > > > > > > > > > > visitors of the web site queries all articles > > in > > > > the > > > > > database by selecting 'author' as the property > > and > > > > > supply the name of the author (xyz) as value. > > > > > > > > > > I am stuck because I need to pass additonal > > > > parameters > > > > > rather than using one pair of property/value > > as > > > > > parameters -- I have this field "category" in > > my > > > > > database. I want to search and get all the > > > > articles > > > > > written by author(property) with name xyz > > (value) > > > > > within; say, the HISTORY category. The value > > of > > > > the > > > > > category will be supplied by the application > > > > developer > > > > > (NOT BY THE VISITOR of the web site via > > selecting > > > > from > > > > > a drop-down list and fill out the value in the > > > > text > > > > > field). > > > > > > > > > > Is there a method signature available in > > Lucene to > > > > > pass additional parameter as necessary? If > > not, > > > > how > > > > > does Lucene handle this kind of situation. > > Thanks > > > > in > > > > > advance. > > > > > > > > > > > > > > > > > > > > __________________________________ > > > > > Do you Yahoo!? > > > > > Protect your identity with Yahoo! Mail > > > > AddressGuard > > > > > http://antispam.yahoo.com/whatsnewfree > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > === message truncated === > > > __________________________________ > Do you Yahoo!? > Protect your identity with Yahoo! Mail AddressGuard > http://antispam.yahoo.com/whatsnewfree > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]