views:

8

answers:

1

I have the following code snippet:

        QueryParser parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_29, new string[] { Field1, Field2, Field3 }, _analyzer);
        parser.SetDefaultOperator(QueryParser.Operator.AND);
        Query queryOrig= parser.Parse(queryString);

        var query = new BooleanQuery();
        query.Add(queryOrig, BooleanClause.Occur.MUST);

        if (itemId.HasValue)
            query.Add(new TermQuery(new Term("Field3", NumericUtils.IntToPrefixCoded(itemId.Value))), BooleanClause.Occur.MUST);

        Hits hits;
        if (sortField != null)
        {
            var sort = new Sort(new SortField(sortField, isDescending));
            hits = Searcher.Search(query, null, sort);
        }
        else
            hits = Searcher.Search(query);

This piece of code is always returning 0 hits no matter what. If I do a direct search using the queryOrig without the boolean, it works fine. I'm quite sure the data is correct.

Thanks, Leonardo

A: 

Well.. It was a data problem! :D The lucene works just fine.

Thanks, Leo!

Homer1980ar