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.
-Gus
QueryParser qp = new QueryParser("contents",analyzer);
qp.setOperator(DEFAULT_OPERATOR);
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();
while(enum.hasMoreElements()){
bq.add( (Query) enum.nextElement(),true/*required*/,false/*not
prohibited*/);
}
hits = searcher.search(bq);
}else{
hits = searcher.search(query);
}
...
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);
setFilter(filter);
vFilters.addElement(tq);
}
}
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, May 28, 2004 4:13 PM
To: [EMAIL PROTECTED]
Subject: Exact Field Match
Hi,
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
value."
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
query
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!
Thanks,
Reece
---------------------------------------------------------------------
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]