How to do SQL IN like query in hibernate search

倾然丶 夕夏残阳落幕 提交于 2019-12-11 08:47:51

问题


A simulating scenario is:

Search for books whose content contains "success" AND author is in a list of passed names(could be thousands of).

I looked into filter: http://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#query-filter

Seams like hibernate search has no native support of this.

What is recommended approach for this problem? I think I am not alone.

Thanks for any inputs.


回答1:


Let me post my current solution.

Get the search results with minimal projections for the keywords, and loop through the results to get only matching ones from the IN list.

I am not using filter.

Open to other alternatives once convinced.




回答2:


If you look here http://lucene.apache.org/java/2_4_1/queryparsersyntax.html (at the end "Field Grouping"), you can write a query with something like :

content:success AND author:("firstname" "secondname" "thirdname" ...)



来源:https://stackoverflow.com/questions/3568055/how-to-do-sql-in-like-query-in-hibernate-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!