Hi all,
       I am taking inputs from an html page with a multiple select box for the 
options. The options can be combined in AND/OR manner and reflect the field to be 
searched upon, that are alraedy indexed ofcourse.
I have extended the MultiFieldQueryParser class for this purpose with the extension 
being the following two methods that I thought would suffice for the AND/OR search 
over multiple fields. But, it behaves like OR option for AND choice.
Can anyone guide me as I am really stuck .

Regards,
Jitender

----------------------------------------------------------------------------
code of two methods in the extended version of the MultiFieldQueryParserclass :
========================================
//supposed to handle the ANDing of the fields ( choosen)
public static Query parseAND(String query, String[] fields, Analyzer analyzer)
 throws ParseException
    {
        BooleanQuery bQuery = new BooleanQuery();
        for (int i = 0; i < fields.length; i++)
        {
            Query q = parse(query, fields[i], analyzer);
            bQuery.add(q, true, false);
        }
        return bQuery;
    }

//supposed to handle the ORing of the fields ( choosen)
    public static Query parseOR(String query, String[] fields, Analyzer analyzer)
 throws ParseException
    {
        BooleanQuery bQuery = new BooleanQuery();
        for (int i = 0; i < fields.length; i++)
        {
            Query q = parse(query, fields[i], analyzer);
            bQuery.add(q, false, false);
        }
        return bQuery;
    }

Reply via email to