Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于DeleteIndex,调用后数据库中的条目虽然删除,但是通过/Home/Index还是可以查询出该数据 #20

Closed
yangbocheng opened this issue Sep 20, 2022 · 11 comments

Comments

@yangbocheng
Copy link
Contributor

请教博主,不知道我是否用法不对
sample中也是这个现象
实测不管是删除,还是update,都会在索引中多一个新条目,而不会删除之前的旧索引
image

所以我目前直接在控制器中提供了一个action,用于完全重置索引。 --暂时解决搜索结果不一致的问题
image

@ldqk
Copy link
Owner

ldqk commented Sep 20, 2022

索引有时删不掉似乎是lucene的问题,你可以参考下我的搜索的最佳实践,我是通过搜索引擎的搜索结果作为条件再到数据库去查询的,因为我的场景是需要做二次过滤,不过你也可以参考我的这种做法,也能解决搜索结果不一致的问题:https://github.com/ldqk/Masuit.MyBlogs/blob/9ad2a436e79744fef5f1aeaca5694fb8fa096504/src/Masuit.MyBlogs.Core/Infrastructure/Services/PostService.cs#L100

@ldqk
Copy link
Owner

ldqk commented Sep 20, 2022

其实这个思路也可以用于补充本库无法做到丰富的条件搜索的场景

@yangbocheng
Copy link
Contributor Author

yangbocheng commented Sep 21, 2022

查找了资料,发现删除不了字段是因为用于deleteIndex的字段,列也被配置为分词了,因此删除索引始终无效
查看源码发现删除时是利用了Id,及IndexId字段,因此对源码中Id的索引设置修改了下,修改后就能正常删除索引了。
但是我的例子是主键是guid,下列代码有效
image

@ldqk
Copy link
Owner

ldqk commented Sep 21, 2022

可以,你提一个pr吧

@yangbocheng
Copy link
Contributor Author

已提交一个pr。 但是换了个修改思路。请博主看看有没有问题
#21

@ldqk
Copy link
Owner

ldqk commented Sep 21, 2022

没问题,已合并

@yangbocheng
Copy link
Contributor Author

博主能发个nuget新包不

@ldqk
Copy link
Owner

ldqk commented Sep 21, 2022

今天之内发一个新包,着急的话你就先用源码吧

@yangbocheng
Copy link
Contributor Author

好滴 谢谢博主。

@ldqk
Copy link
Owner

ldqk commented Sep 21, 2022

已发最新包

@yangbocheng
Copy link
Contributor Author

新包已解决 多谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants