Hi All,
I am getting Null Value in TopGroups<Integer> ScoreHits = parentblockjoincollector.getTopGroups.(...) .Please Help Out. Attached the Code with the mail.
public void ExpMatchManager( ) throws IOException, SQLException, ClassNotFoundException { CandidateSkillMatrix candidateskillDAO = new CandidateSkillMatrix(); ArrayList<CandidateSkillMatrixBean> lstcandidateskillBean = new ArrayList<CandidateSkillMatrixBean>(); StandardAnalyzer standardAnalyzer = new StandardAnalyzer( Version.LUCENE_41); Directory dir = new RAMDirectory(); IndexWriterConfig indexConfig = new IndexWriterConfig( Version.LUCENE_41, standardAnalyzer); IndexWriter indexwriter = new IndexWriter(dir, indexConfig); int counter = 0; String TotalExp = ""; List<Document> lstDocuments = new ArrayList<Document>(); BooleanQuery booleanQuery = new BooleanQuery(); String ReqID1 ="1"; String JobDescription1 ="Expertise in Manual Testing"; String skillMandatory1 =" Manual Testing and QTP"; String skillDesired1 = " Communication skills"; String JobDetails1 = JobDescription1 + skillMandatory1 + skillDesired1; //lstreqskill = reqskillMatrixDAO.getDataByID(ReqID); String Skill1="Manual Testing"; String ExperienceInYears1="1"; lstDocuments.add(ChildDetailsForReq(Skill1, ExperienceInYears1)); lstDocuments.add(ParentDetailsForReq(ReqID1, JobDetails1)); indexwriter.addDocuments(lstDocuments); lstDocuments.clear(); String ReqID2="2"; String JobDescription2=" Best in Testing"; String skillMandatory2=" Testing"; String skillDesired2=""; String JobDetails2=JobDescription2 +""+ skillMandatory2 +""+ skillDesired2; String Skill2="QTP"; String Skill3="Testing"; String ExperienceInYears2="2"; lstDocuments.add(ChildDetailsForReq(Skill2,ExperienceInYears2)); lstDocuments.add(ChildDetailsForReq(Skill3, ExperienceInYears2)); lstDocuments.add(ParentDetailsForReq(ReqID2, JobDetails2)); indexwriter.addDocuments(lstDocuments); String skillName=""; //CandidateExpMatchManager objcandidateExpMatchManager = new CandidateExpMatchManager(); //CommonClass commonclass = new CommonClass(); //int ClientID = commonclass.getclientID("SH"); //RequirementDAO reqDao = new RequirementDAO(); //ArrayList<RequirementBean> listRequirement = reqDao //.getAllActiveData(ClientID); ///ArrayList<CandidateBean> lstcandidate = new ArrayList<CandidateBean>(); //CandidateDAO candidateDAO = new CandidateDAO(); //lstcandidate = candidateDAO.getDataByID(223); //int CandidateID = canddidatebean.getCandidateID(); //String Candidateid = Integer.toString(CandidateID); //lstcandidateskillBean = candidateskillDAO // .getCandidateSkillByID("223"); int thirdcounter = 0; //while (thirdcounter < lstcandidateskillBean.size()) { skillName = "QTP"; String TotalYearOfExp = "1"; String skillname1="Manual Testing"; String TotalYearOfExp1 = "1"; //TotalExp = Integer.toString(TotalYearOfExp); Query childQuery = new TermQuery(new Term("skills", skillName)); //Query childQuery = new TermQuery(new Term("skills", skillName)); //Query childQuery1 = new TermQuery(new Term("YearOfExp", TotalYearOfExp)); booleanQuery.add(childQuery, Occur.SHOULD); //booleanQuery.add(childQuery1, Occur.MUST); //thirdcounter++; //} indexwriter.commit(); IndexReader indexreader = DirectoryReader.open(dir); IndexSearcher indexsearch = new IndexSearcher(indexreader); Query ParentQuery = new TermQuery(new Term("doctype", "ParentReqDetails")); Filter ParentFilter = new CachingWrapperFilter(new QueryWrapperFilter( ParentQuery)); // booleanQuery.add(); ScoreMode scoreMode = ScoreMode.Max; ToParentBlockJoinQuery toparentBlockJoinQuery = new ToParentBlockJoinQuery( booleanQuery, ParentFilter, scoreMode); BooleanQuery booleanQuery2 = new BooleanQuery(); //booleanQuery2.add(new TermQuery(new Term("JobReq", skillName)), // Occur.SHOULD); booleanQuery2.add(toparentBlockJoinQuery, Occur.SHOULD); ToParentBlockJoinCollector parentblockjoincollector = new ToParentBlockJoinCollector( Sort.RELEVANCE, // sort 10, // numHits true, // trackScores false // trackMaxScore ); indexsearch.search(booleanQuery2, parentblockjoincollector); TopGroups<Integer> ScoreHits = parentblockjoincollector.getTopGroups( toparentBlockJoinQuery, Sort.RELEVANCE, 0, // offset 10, // maxDocsPerGroup 0, // withinGroupOffset true); int scorecounter = 0; while (counter < ScoreHits.groups.length) { System.out.println(indexsearch.doc( ScoreHits.groups[counter].groupValue).get("JobReq")); System.out.println(ScoreHits.groups[counter].maxScore); System.out.println(ScoreHits.groups[counter].score); scorecounter++; } } // need to add company and location after succesful execution of code public static Document ParentDetailsForReq(String ReqID, String Requirement) { Document document = new Document(); document.add(new Field("ReqID", ReqID, StringField.TYPE_STORED)); document.add(new Field("JobReq", Requirement, StringField.TYPE_STORED)); document.add(new Field("doctype", "ParentReqDetails", StringField.TYPE_STORED)); return document; } public Document ChildDetailsForReq(String Skills, String Experience) { Document document = new Document(); document.add(new Field("Skills", Skills, StringField.TYPE_STORED)); document.add(new Field("Experience", Experience, StringField.TYPE_STORED)); return document; } public static void main(String[] args) throws ClassNotFoundException, IOException, SQLException { // TODO Auto-generated method stub TestCandidateMatchOnExp testCandidateMatchOnExp=new TestCandidateMatchOnExp(); testCandidateMatchOnExp.ExpMatchManager(); // testCandidateMatchOnExp.ExpMatchManager(lstRequirement, canddidatebean) }
--------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org