次のマップ/変換があります
public class PositionSearch : AbstractIndexCreationTask<Employer>
{
public PositionSearch()
{
Map = employers =>
from employer in employers
from position in employer.Positions
select new
{
EmployerName = employer.Name,
SearchSkills = position.RequiredSkills
.Select(x => x.Skill)
};
TransformResults = (database, results) =>
from result in results
from position in result.Positions
select new
{
EmployerId = result.Id,
EmployerName = result.Name,
PositionId = position.Id,
PositionTitle = position.Title,
RequiredSkills = position.RequiredSkills
.Select(x => new { x.Skill, x.Proficiency })
};
// Any field you are going to use .Search() on should be analyzed.
Index("SearchSkills", FieldIndexing.Analyzed);
}
}
それぞれが単一のスキル「NH」と「MVC」を持つ 2 つのポジションを持つ雇用主オブジェクトがあります。
次のクエリを実行すると、1 つを期待していたときに、2 つの位置結果が返されます。なぜこれがこのように振る舞うのか誰か教えてもらえますか? 私が実行している結合と関係があるような気がしますが、よくわかりません。
using (var session = DocumentStore.OpenSession())
{
var results = session.Query<PositionSearchResultModel, PositionSearch>()
.Customize(x => x.WaitForNonStaleResults())
.Search(x => x.SearchSkills, "NH")
.OfType<PositionSearchResultModel>().ToList();
Assert.AreEqual(1, results.Count());
}
順序付けのために Temp-Index-Score メタ データにアクセスできるように変換を使用したいのですが、これまで変換なしではメタ データにアクセスできませんでした。