QueryParser qp = new QueryParser("default", new DSAnalyzer());
QueryParser qp = new QueryParser("default", DSIndexer.getAnalyzer());
    public static QueryResults doQuery(Context c, QueryArgs args)            throws IOException    {        String querystring = args.getQuery();        QueryResults qr = new QueryResults();        List hitHandles = new ArrayList();        List hitTypes = new ArrayList();        // set up the QueryResults object        qr.setHitHandles(hitHandles);        qr.setHitTypes(hitTypes);        qr.setStart(args.getStart());        qr.setPageSize(args.getPageSize());        // massage the query string a bit        querystring = checkEmptyQuery(querystring); // change nulls to an empty        // string        querystring = workAroundLuceneBug(querystring); // logicals changed to        // && ||, etc.        querystring = stripHandles(querystring); // remove handles from query        // string        querystring = stripAsterisk(querystring); // remove asterisk from        // beginning of string        try        {            // grab a searcher, and do the search            Searcher searcher = getSearcher(ConfigurationManager                    .getProperty("search.dir"));            QueryParser qp = new QueryParser("default", new DSAnalyzer());            log.info("Final query string: " + querystring);            Query myquery = qp.parse(querystring);            Hits hits = searcher.search(myquery);            // set total number of hits            qr.setHitCount(hits.length());            // We now have a bunch of hits - snip out a 'window'            // defined in start, count and return the handles            // from that window            // first, are there enough hits?            if (args.getStart() < hits.length())            {                // get as many as we can, up to the window size                // how many are available after snipping off at offset 'start'?                int hitsRemaining = hits.length() - args.getStart();                int hitsToProcess = (hitsRemaining < args.getPageSize()) ? hitsRemaining                        : args.getPageSize();                for (int i = args.getStart(); i < (args.getStart() + hitsToProcess); i++)                {                    Document d = hits.doc(i);                    String handleText = d.get("handle");                    String handletype = d.get("type");                    hitHandles.add(handleText);                    if (handletype.equals("" + Constants.ITEM))                    {                        hitTypes.add(new Integer(Constants.ITEM));                    }                    else if (handletype.equals("" + Constants.COLLECTION))                    {                        hitTypes.add(new Integer(Constants.COLLECTION));                    }                    else if (handletype.equals("" + Constants.COMMUNITY))                    {                        hitTypes.add(new Integer(Constants.COMMUNITY));                    }                    else                    {                        // error! unknown type!                    }                }            }        }        catch (NumberFormatException e)        {            log                    .warn(LogManager.getHeader(c, "Number format exception", ""                            + e));            qr.setErrorMsg("Number format exception");        }        catch (ParseException e)        {            // a parse exception - log and return null results            log.warn(LogManager.getHeader(c, "Invalid search string", "" + e));            qr.setErrorMsg("Invalid search string");        }        catch (TokenMgrError tme)        {            // Similar to parse exception            log                    .warn(LogManager.getHeader(c, "Invalid search string", ""                            + tme));            qr.setErrorMsg("Invalid search string");        }        catch(BooleanQuery.TooManyClauses e)        {            log.warn(LogManager.getHeader(c, "Query too broad", e.toString()));            qr.setErrorMsg("Your query was too broad. Try a narrower query.");        }        return qr;    }