私は次のようなドキュメント構造を持っています:
Employer => Positions => RequiredSkills
雇用主にはポジションのコレクションがありますポジション
にはRequiredSkillのコレクションがあります。
必要なスキルは、スキル(文字列)と習熟度(列挙型)で構成されます。
動的インデックスを使用すると、会社は正常に返されるように見えますが、インデックスを使用してMVCビューモデルにデータを入力し、UIに戻りたいと思います。
私はレイヴンに本当に慣れていないので、愚かな/不必要なことをしてしまったことをお詫びします!
私は次のマッピングを持っています:
public class PositionSearch : AbstractIndexCreationTask<Employer>
{
public PositionSearch()
{
Map = employers =>
from employer in employers
from position in employer.Positions
select new
{
EmployerId = employer.Id,
EmployerName = employer.Name,
PositionId = position.Id,
PositionTitle = position.Title,
position.Location,
position.Description,
RequiredSkills = position.RequiredSkills
};
StoreAllFields(FieldStorage.Yes);
Index("RequiredSkills_Skill", FieldIndexing.Analyzed);
}
}
ただし、次のクエリを実行しようとすると、次のようになります。
var results = session.Query<PositionSearchResultModel, PositionSearch>()
.Customize(x => x.WaitForNonStaleResults())
.Where(x=>x.RequiredSkills.Any(y=>y.Skill == "SkillName"))
.ProjectFromIndexFieldsInto<PositionSearchResultModel>()
.ToList();
次のエラーが発生します。
System.ArgumentException:
The field 'RequiredSkills_Skill' is not indexed,
cannot query on fields that are not indexed
誰かが私が間違っていることを確認したり、私のために別のアプローチを提案したりできますか?
ありがとう、
ジェームズ
ビューモデルを更新する-ありがとう:
public class PositionSearchResultModel
{
public PositionSearchResultModel()
{
RequiredSkills = new HashSet<SkillProficiency>();
}
public string EmployerId { get; set; }
public string EmployerName { get; set; }
public string PositionId { get; set; }
public string PositionTitle { get; set; }
public string Location { get; set; }
public string Description { get; set; }
public ICollection<SkillProficiency> RequiredSkills { get; set; }
}