Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can you add numeric fields in Nhibernate.Search?
    text
    copied!<p>I recently mitakenly assumed that Nhibernate.Search would index an integer property on my class as a numeric field.</p> <pre><code>[Indexed] public class Location : Entity { [IndexedEmbedded(Depth = 1, Prefix = "Country_")] public virtual Country Country { get; set; } [Field(Index.Tokenized)] public virtual string Name { get; set; } [Field(Index.Tokenized)] public virtual string AlternativeNames { get; set; } [Field(Index.Tokenized)] public virtual string OriginalNames { get; set; } [Field(Index.UnTokenized)] public virtual string LocationType { get; set; } [Field()] public virtual int? Population { get; set; } } </code></pre> <p>But when I set the sort for the query like so:</p> <pre><code> var words = query.Split(' '); var luceneQuery = string.Join(" AND ", words.Select(x =&gt; "Name:{0}*".F(x))); luceneQuery += " AND LocationType:locality"; var results = search.CreateFullTextQuery&lt;Location&gt;(luceneQuery) .SetSort(new Sort(new SortField("Population", CultureInfo.CurrentCulture, true))) .SetMaxResults(100) .List&lt;Location&gt;(); </code></pre> <p>It returns results ordered by the numbers in the same style as a word sort like this:</p> <pre><code>City Country Region Population New London United States North America 998 Nueva Londres Paraguay South America 971 New London United States North America 967 Londonderry United Kingdom British Islands 92133 London Kiribati Micronesia 921 London United States North America 8122 London United Kingdom British Islands 7869322 New London United States North America 7316 </code></pre> <p>So my question is, as Nhibernate.Search is treating this as a text field, how can I change it to a numeric field and is it possible to convert or do I have to reindex every single record. 340K of them.</p> <p>I am starting to feel the convenience of Nhibernate.Search is lost if it cannot do this. Maybe I will have to start over and use normal Lucene.Net?</p> <p>Thanks for any help</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload