मैं निम्नलिखित की तरह एक दस्तावेज़ संरचना है:RavenDb स्थिर सूचकांक: बच्चे संग्रह पर क्वेरी वस्तुओं
Employer => Positions => RequiredSkills
नियोक्ता स्थिति
पदों RequiredSkill का एक संग्रह है का संग्रह है।
आवश्यक कौशल में एक कौशल (स्ट्रिंग) और एक प्रवीणता (enum) शामिल है।
यदि मैं एक गतिशील सूचकांक का उपयोग करता हूं तो ऐसा लगता है कि कंपनी ठीक है, हालांकि मैं यूआई में वापस आने के लिए एमवीसी व्यू मॉडल को पॉप्युलेट करने के लिए एक इंडेक्स का उपयोग करना चाहता हूं।
मैं वास्तव में रेवेन के लिए नया हूं इसलिए बेवकूफ/अनावश्यक कुछ करने के लिए मेरी माफ़ी!
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; }
}
आप इंडेक्स परिणामों के साथ इंडेक्स प्रविष्टियों को भ्रमित कर रहे हैं। कृपया अपना 'PositionSearchResultModel' क्लास प्रदान करें और मैं एक पूर्ण समाधान के साथ जवाब दूंगा। धन्यवाद। –
मेरा दृश्य मॉडल जोड़ा गया। – Jamez
मुझे लगता है कि आप क्षेत्र के रूप में चिह्नित करने की कोशिश कर रहे थे। क्या आप कौशल नाम पर एक सटीक मैच चाहते हैं? या आप एक विश्लेषण खोज करना चाहते थे? –