2010/11/29 Anshum <ansh...@gmail.com> > 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. > Thanks,got it. Is any performance between them?
> Also, having "No" to be escaped while query formation is, by using > appropriate query parser. In fact, I am working with the Chinese characters search. So I am using the IKAnalyzer at http://code.google.com/p/ik-analyzer/. And I use the built-in IKQueryParser. > You may also use an analyzer and search for all > terms as optional i.e. an OR query in conjunction with > setMinimumNumberShouldMatch > > http://lucene.apache.org/java/3_0_1/api/core/org/apache/lucene/search/BooleanQuery.html#setMinimumNumberShouldMatch(int)<http://lucene.apache.org/java/3_0_1/api/core/org/apache/lucene/search/BooleanQuery.html#setMinimumNumberShouldMatch%28int%29> > < > http://lucene.apache.org/java/3_0_1/api/core/org/apache/lucene/search/BooleanQuery.html#setMinimumNumberShouldMatch(int)<http://lucene.apache.org/java/3_0_1/api/core/org/apache/lucene/search/BooleanQuery.html#setMinimumNumberShouldMatch%28int%29> > > :(. Since I am using the hibernate search3.2.1,its lucene model is 2.9.3... > Finally > all would depend on the case at hand and what you think is the > expected behavior of search. > Hope this helps. > -- > Anshum Gupta > http://ai-cafe.blogspot.com > > > On Mon, Nov 29, 2010 at 1:31 PM, yang Yang <m4ecli...@gmail.com> 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"? > > >