Re: AND query in SHOULD

2007-11-24 Thread Shai Erera
Hi Not sure I understand the question. You can add as many keywords as you want to the query (like \"green tree\" \"short road\" sky bird) and it should behave the same (i.e., search in each field. Shai On Nov 24, 2007 10:26 AM, Rapthor <[EMAIL PROTECTED]> wrote: > > Thanks for this example. I

Re: AND query in SHOULD

2007-11-24 Thread Rapthor
Thanks for this example. I am uncertain about one detail: How do I achieve a search for multiple keywords. Not just "green tree" but also "short road", "sky", "bird"? Is there a chance to add those keywords to the "Query q = qp.parse("\"green tree\"");" command? Shai Erera wrote: > > How about

Re: AND query in SHOULD

2007-11-22 Thread Shai Erera
How about using MultiFieldQueryParser. Here is a short main I wrote: Directory dir = new RAMDirectory(); Analyzer analyzer = new StandardAnalyzer(); IndexWriter writer = new IndexWriter(dir, analyzer); Document doc = new Document(); doc.add(new Field("field1

Re: AND query in SHOULD

2007-11-22 Thread Erick Erickson
The semantics of the phrase query you're constructing probably aren't what you think. As best I can infer, you are trying to do something like "green tree" in field1 or "green tree" in field 2 but that's not even close to what you're constructing. It would help a show what the query you want is

Re: AND query in SHOULD

2007-11-22 Thread Rapthor
There is no option to provide an Occur.SHOULD to the PhraseQuery. So where does it go? I changed the source to look like this: PhraseQuery pq = new PhraseQuery(); for (String word : words) { for (String field : fields) { pq.add(new Term(field, word)); } } Hits hits

Re: AND query in SHOULD

2007-11-22 Thread Daniel Naber
On Donnerstag, 22. November 2007, Rapthor wrote: > I want to realize a search that finds the exact phrase I provide. You simply need to create a PhraseQuery. See http://lucene.zones.apache.org:8080/hudson/job/Lucene-Nightly/javadoc/org/apache/lucene/search/PhraseQuery.html Regards Daniel --