私は最近、Nhibernate.Searchがクラスの整数プロパティを数値フィールドとしてインデックス付けすることを誤って想定しました。
[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; }
}
しかし、クエリの並べ替えを次のように設定すると、次のようになります。
var words = query.Split(' ');
var luceneQuery = string.Join(" AND ", words.Select(x => "Name:{0}*".F(x)));
luceneQuery += " AND LocationType:locality";
var results = search.CreateFullTextQuery<Location>(luceneQuery)
.SetSort(new Sort(new SortField("Population", CultureInfo.CurrentCulture, true)))
.SetMaxResults(100)
.List<Location>();
次のような単語の並べ替えと同じスタイルで、番号順に結果を返します。
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
だから私の質問は、Nhibernate.Searchがこれをテキストフィールドとして扱っているので、どうすればそれを数値フィールドに変更でき、変換することができますか、またはすべてのレコードのインデックスを再作成する必要がありますか?それらの340K。
Nhibernateの便利さを感じ始めています。これができないと検索が失われます。たぶん、最初からやり直して、通常のLucene.Netを使用する必要がありますか?
助けてくれてありがとう