Hey guys,
I want to filter a result set on a particular field..I have code like this

try
       {
           PhraseQuery textQuery = new PhraseQuery();
           PhraseQuery titleQuery = new PhraseQuery();
           PhraseQuery catQuery = new PhraseQuery();
           textQuery.setSlop( 20 );
           titleQuery.setSlop( 4 );

           for( int k = 0; k < phrase.length; k++ )
           {
               textQuery.add( new Term( NAME, phrase[k] ) );
               titleQuery.add( new Term( REVIEW, phrase[k] ) );


           }
           bQuery.add( textQuery, BooleanClause.Occur.SHOULD );
           bQuery.add( titleQuery, BooleanClause.Occur.SHOULD );

           if(category!=null && !category.equals("")){
            catQuery.add( new Term( TYPE, category ) );
            bQuery.add(catQuery,BooleanClause.Occur.MUST);

           }

       }
       catch( Exception e )
       {
           throw new RuntimeException( "Unable to make any sense of the
query.", e );
       }



Now the problem is its getting all results for a particular category
regardless the "phrase" is  in the title or text field which make sense as
the other two have SHOULD clause. the problem is I can not set a MUST clause
on the other two field as I need to match either one of the field. so what i
want to is either title or text MUST have it and if category is not null it
MUST have the category string passed. any ideas

Reply via email to