lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anshum <>
Subject Re: What is the difference between the "AND" and "+" operator?
Date Mon, 29 Nov 2010 08:23:52 GMT
Hi Yang,
About the difference between a filter and a query, the essential one is,
filter does not calculate score/relevance and so the sort would vary.
Also, having "No" to be escaped while query formation is, by using
appropriate query parser. You may also use an analyzer and search for all
terms as optional i.e. an OR query in conjunction with
all would depend on the case at hand and what you think is the
expected behavior of search.
Hope this helps.
Anshum Gupta

On Mon, Nov 29, 2010 at 1:31 PM, yang Yang <> wrote:

> 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"?

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