You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "reza1370programmer (via GitHub)" <gi...@apache.org> on 2023/04/26 11:34:51 UTC
[GitHub] [lucenenet] reza1370programmer opened a new issue, #842: for some reasons lucene create duplicate data while searching
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: dev-unsubscribe@lucenenet.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] for some reasons lucene create duplicate data while searching [lucenenet]
Posted by "NightOwl888 (via GitHub)" <gi...@apache.org>.
NightOwl888 commented on issue #842:
URL: https://github.com/apache/lucenenet/issues/842#issuecomment-1755129526
I am closing this because it is not a bug that needs addressing in Lucene.NET. Please direct usability questions to StackOverflow or the [Lucene.NET user mailing list](https://lucenenet.apache.org/contributing/index.html#ask-a-question). You will be much more likely to get an answer to your question on StackOverflow when specifying both `lucene.net` and `lucene` tags.
--
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: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] for some reasons lucene create duplicate data while searching [lucenenet]
Posted by "NightOwl888 (via GitHub)" <gi...@apache.org>.
NightOwl888 closed issue #842: for some reasons lucene create duplicate data while searching
URL: https://github.com/apache/lucenenet/issues/842
--
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: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [lucenenet] laimis commented on issue #842: for some reasons lucene create duplicate data while searching
Posted by "laimis (via GitHub)" <gi...@apache.org>.
laimis commented on issue #842:
URL: https://github.com/apache/lucenenet/issues/842#issuecomment-1533098322
When you say "creates duplicate data", what do you mean by that? The code snippet you posted does not appear to be doing any kind of index writing, so it does not seem like the issue is somewhere in Lucene and could be somewhere in your code.
--
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: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org