Thanks for the reply. I tried all kinds of combinations

new TermQuery(new Term("P", "True"));

new TermQuery(new Term("P", "1"));

etc.

My code look like this (it works fine for other fields):

public IList<Bla> Query(string term, out int total, int page, int pageSize)
{
    if (term.ToString().Equals("") == false)
    {
        var parser = new
MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_29, new[] { "Query" },
new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29));
        Query query = parser.Parse(term);

        IFullTextSession session =
Search.CreateFullTextSession(this.Session);
        IQuery fullTextQuery = session.CreateFullTextQuery(query, new[] {
typeof(Bla) });
        total = fullTextQuery.List<Bla>().Count();
        return fullTextQuery.List<Bla>().Skip((page - 1) *
pageSize).Take(pageSize).ToList<Bla>();
    }
    else
    {
        total = 0;
        return null;
    }
}

-----Original Message-----
From: Robert Jordan [mailto:robe...@gmx.net] 
Sent: 08 March 2011 13:49
To: lucene-net-u...@incubator.apache.org
Subject: [Spam] Re: [Lucene.Net] boolean value search

On 08.03.2011 14:11, Christian Setzkorn wrote:
> Hi,
>
>
>
> I have a class that contains a Boolean value:
>
>
>
> [Field(Index.UnTokenized, Store = Store.No)]
>
> public virtual bool P { get; set; }
>
> What is the query syntax to find objects where P = True? I tried any
> imaginable combination with no avail.


It depends on how your software (looks like it's based on
NHibernate) is mapping class fields to Lucene field names
and how values are stored.

Usually, finding something as simple as an untokenized
field evolves around creating a simple TermQuery for
a given field name and the value to be searched for:

new TermQuery(new Term("your field name", "some value"));

Robert

Reply via email to