lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morus Walter <>
Subject Re: Rephrase My Question - How To Search Database With More Than One Pair of Property/Value as Parameters Using Lucene?
Date Thu, 06 Nov 2003 08:34:11 GMT
Caroline Jen writes:

> 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);

Is it? Which type of lucene object has such a method?
> 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?
I don't think so.

The method signature for a search in lucene is (in the easiest case)
hits = search(query)
where search is a method of a searcher object, and query is a query object.
Basically there are two ways to create a query object:
a) use the query parser
b) construct it yourself

Option a) allowes to formulate queries with the options described in
For a single field a query might look like 'some term' with the
field defined as the default field.
To search other fields than the default field, you can use <fieldname>:term.
To combine subqueries you can use logical operators like AND, OR...
So a query might look like
creator:Castro AND category:computer

If you want to construct the query yourself you have to look at the
API docs and the different types of query subclasses.
E.g. you could combine two TermQuery objects with a BooleanQuery object.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message