lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yang Yang <m4ecli...@gmail.com>
Subject What is the difference between the "AND" and "+" operator?
Date Mon, 29 Nov 2010 08:01:37 GMT
What is the difference between the "AND" and "+" operator?

ALso,what is the difference between a query and a filter?
For example
String[] fields={"name","address","classId"};
If I want to search the document whose classId is '4" and whose name or
address contain "Zhongzhou Road No 200",I can use two manner:
1) filter
Query q=new MKultipleFieldParser(.....).parse("Zhongzhou Road No 200");
new IndexSearcher(...).search(q,new TermFilter(new
Term("classId","4")),100);

ALso I can use:
Query q=new MKultipleFieldParser(.....).parse("Zhongzhou Road No 200");
Query classQ=new TermQuery(new Term("classId","4"));
Query all=new BooleanQuery();
all.add(q,Occur.MUST);
all.add(classQ,occur.Must);
new IndexSearcher(...).search(all,null,100);

What is the difference?

BTW,in the above exmaple,if I search "Zhongzhou Road No 200",I get no
result,however I can get some results if I search "Zhongzhou Road No
200",because there is not a term named "No" in the index.
And the search string are from client side,how to make the document contain
"Zhongzhou Road 200" can be returned when search "Zhongzhou Road No 200"?

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message