Lucene will generally do the right thing without much help - docs with more matches will score better and thus be presented first. But you can give it a helping hand, perhaps with some query boosting: build a boolean query and add an AND query with a positive boost, then an OR query with smaller or no boost. Or do as you suggest: do an AND query and if you get enough hits, quit, otherwise do an OR query and add those results (deduped) to the first list. Proximity qualifiers, or span queries, can be helpful too, again with boost, so that docs with "xxx lucene document yyy" can be made to score higher than "xxx lucene aaa bbb ccc ddd some other junk document".
What is "best" is debatable, and dependent on your data and users. Keeping everybody happy all the time is hard! -- Ian. On Tue, Nov 16, 2010 at 9:40 AM, maven apache <apachemav...@gmail.com> wrote: > Hi: > There are types of TermQuery,TermRangeQuery,and the BooleanQuery and etc > built in lucene,and they can be combined to make a powerful search. > > However I wonder if this is useful for a user in the client side? > > For example,I build a web user interface with a search textfield(like the > google) for inputting,when user enter something to the textfield,I got it > and do the searching. > > Now is that mean I should do something to the string from user? > > Suppose user enter "lucene document" for searching, then I can change them > to "lucene AND document" or "lucene OR document" or "+lucene-document" or > .... and something else. > > But the problem is that how did I know the intention of the user? > > > BTW,In my opinion there is always a contradiction between the *quantity* and > *quality* of the search result. > > That's to say if I want the search result as precise as possible I should > use the "Lucene AND document" instead of the user entered string,however if > there is no precise result,it seems that I should use the "lucene or > document"(just return something to user). > > So I am confused how to handle these problem. > > PS: > Maybe this topic is not very a lucene question,but it is search related, and > you guys are experter of searching,so I asked for help. :) > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org