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. 

I am using this code:

 

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>();

 

By the way is there a better way to determine the total when I use paging
like here?

 

Thanks.

 

Christian

 

PS:

 

This is how I index:

 

public void BuildSearchIndex()

{

 

    FSDirectory entityDirectory = null;

    IndexWriter writer = null;

 

    var entityType = typeof(MappedSequence);

 

    var indexDirectory = new DirectoryInfo(GetIndexDirectory());

 

    if (indexDirectory.Exists)

    {

                indexDirectory.Delete(true);

    }

 

    try

    {

                entityDirectory =
FSDirectory.GetDirectory(Path.Combine(indexDirectory.FullName,
entityType.Name), true);

                writer = new IndexWriter(entityDirectory, new
StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29), true,
IndexWriter.MaxFieldLength.UNLIMITED);

    }

    finally

    {

                if (entityDirectory != null)

                {

                    entityDirectory.Close();

                }

 

                if (writer != null)

                {

                    writer.Close();

                }

    }

 

    IFullTextSession fullTextSession =
Search.CreateFullTextSession(this.Session);

    // Iterate through Suppliers and add them to Lucene's index

    foreach (MappedSequence instance in
Session.CreateCriteria(typeof(MappedSequence)).List<MappedSequence>())

    {

                fullTextSession.Index(instance);

    }

}

 

private string GetIndexDirectory()

{

    INHSConfigCollection nhsConfigCollection =
CfgHelper.LoadConfiguration();

    string property =
nhsConfigCollection.DefaultConfiguration.Properties["hibernate.search.defaul
t.indexBase"];

    var fi = new FileInfo(property);

    return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fi.Name);

}

Reply via email to