reza1370programmer opened a new issue, #842:
URL: https://github.com/apache/lucenenet/issues/842

   hi every body.i am using lucene.net beta version for .net core 6.
   in my project when you search something after getting result every thing is 
ok but if you refresh page for current data lucene will create duplicate data i 
dont know what is problem exactly and so confused
   
   `   public IEnumerable<LuceneDto> Search(SearchParams searchParams)
           {
               var _directory = FSDirectory.Open(new 
DirectoryInfo(Path.Combine(System.IO.Directory.GetCurrentDirectory(), 
"wwwroot", "LuceneData")));
               var directoryReader = DirectoryReader.Open(_directory);
               var indexSearcher = new IndexSearcher(directoryReader);
               var query = new BooleanQuery();
               var query2 = new BooleanQuery();
               var query3 = new BooleanQuery();
   
               if (searchParams.searchKey != null)
               {
                   searchParams.searchKey = 
searchParams.searchKey.Trim().Replace("  ", " ").Replace("*", "");
                   var parts = searchParams.searchKey?.Split(' ');
                   foreach (var part in parts)
                   {
   
                       query.Add(new FuzzyQuery(new Term("tablo", part), 1), 
Occur.SHOULD);
                       query.Add(new FuzzyQuery(new Term("service_description", 
part), 1), Occur.SHOULD);
                       query.Add(new WildcardQuery(new Term("tablo", $"{'*' + 
part + '*'}")), Occur.SHOULD);
                       query.Add(new WildcardQuery(new 
Term("service_description", $"{'*' + part + '*'}")), Occur.SHOULD);
                   }
               }
               if (searchParams.cityId > 0)
               {
                   Term term = new Term("locationId", 
searchParams.cityId.ToString());
                   query2.Add(new TermQuery(term), Occur.MUST);
                   query3.Add(query2, Occur.MUST);
               }
               else
                   query3.Add(query2, Occur.SHOULD);
   
               query3.Add(query, Occur.MUST);
   
               var hits = indexSearcher.Search(query3, 20, 
Sort.RELEVANCE).ScoreDocs.Skip((searchParams.pageIndex - 1) * 5).Take(5);
               var places = new List<LuceneDto>();
               foreach (var hit in hits)
               {
                   var document = indexSearcher.Doc(hit.Doc);
                   places.Add(new LuceneDto
                   {
                       tablo = document.Get("tablo"),
                       service_description = 
document.Get("service_description"),
                       Id = Int64.Parse(document.Get("Id")),
                       address = document.Get("address"),
                       bussiness_pic1 = document.Get("bussiness_pic1"),
                       bussiness_pic2 = document.Get("bussiness_pic2"),
                       bussiness_pic3 = document.Get("bussiness_pic3"),
                       email = document.Get("email"),
                       fax = document.Get("fax"),
                       instagram = document.Get("instagram"),
                       telegram = document.Get("telegram"),
                       whatsapp = document.Get("whatsapp"),
                       website = document.Get("website"),
                       mob1 = document.Get("mob1"),
                       mob2 = document.Get("mob2"),
                       phone1 = document.Get("phone1"),
                       phone2 = document.Get("phone2"),
                       phone3 = document.Get("phone3"),
                       personal_pic = document.Get("personal_pic"),
                       visitCart_front = document.Get("visitCart_front"),
                       visitCart_back = document.Get("visitCart_back"),
                       manager = document.Get("manager"),
                       like_count = int.Parse(document.Get("like_count")),
                       view_count = int.Parse(document.Get("view_count")),
                       locationId = int.Parse(document.Get("locationId")),
                       userId = Int64.Parse(document.Get("userId")),
                       StatusId = int.Parse(document.Get("statusId")),
                       on_off = document.Get("on_off"),
                       special_message = document.Get("special_message"),
                       taparcode = document.Get("taparcode"),
                       workTimeId = int.Parse(document.Get("workTimeId")),
                       saturday = int.Parse(document.Get("saturday")),
                       sunday = int.Parse(document.Get("sunday")),
                       monday = int.Parse(document.Get("monday")),
                       tuesday = int.Parse(document.Get("tuesday")),
                       wednesday = int.Parse(document.Get("wednesday")),
                       thursday = int.Parse(document.Get("thursday")),
                       friday = int.Parse(document.Get("friday"))
   
                   });
               }
               _directory.Dispose();
               directoryReader.Dispose();
               _analyzer.Dispose();
               return places;
           }`
   thank you for your consideration


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to