lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jitender ahuja" <ajiten...@aalayance.com>
Subject how to ensure that AND occurs, pl. help
Date Fri, 09 Jul 2004 07:57:43 GMT
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;
    }

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message