lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gus Kormeier <>
Subject RE: Exact Field Match
Date Sat, 29 May 2004 00:08:32 GMT
Yes, you can.  
And others probably have a much better example than mine...

There is probably a wiki or other document describing it.

You can chain queries together with BooleanQuery.  I am creating a Vector of
Query's based on restriction criteria off my site and then loading them into
the BooleanQuery.
You might check out WildCardQuery which works well with/without wildcard
parameters inside it.

       QueryParser qp = new QueryParser("contents",analyzer);
 	 Query query = qp.parse(queryline);

       if(vFilters != null && vFilters.size() > 0){
          BooleanQuery bq = new BooleanQuery();
          bq.add(query,true/*required*/,false/*not prohibited*/);
          Enumeration enum = vFilters.elements();
            bq.add( (Query) enum.nextElement(),true/*required*/,false/*not
	   hits =;

	   hits =;

  public void setFilter(String fieldname,String fieldvalue){
       if(fieldname != null && fieldvalue != null &&
          fieldname.length() > 0 && fieldvalue.length() > 0){
          if(fieldvalue.indexOf("?") == -1){
             fieldvalue += "?";
          Term t = new Term(fieldname,fieldvalue);
          WildcardQuery tq = new WildcardQuery(t);
          Filter myfilter = new QueryFilter(tq);

-----Original Message-----
From: []
Sent: Friday, May 28, 2004 4:13 PM
Subject: Exact Field Match


Does Lucene have support for exact field match?  Is there a way to
say that this field equals exactly this value?  I know I can do it by using
an untokenized field.  But I have some values that I would want to store in
both tokenized and untokenized copies of the same field.  Instead of doing
that I'm just storing the tokenized version.

For example:
MyField = "My

I want to search where "My value." is the exact match for this
field but I also sometime want to do a containing search so that just a
for "value" matches.  

I'm planning on extracting the stored value and
comparing it to see if its an exact match.  If you have a better idea please
send it my way!


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

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

View raw message