Filters in Lucene

╄→гoц情女王★ 提交于 2019-12-25 03:26:16

问题


Friends,

I am new to lucene full text search. i have developed page with full text seach. it works fine till. but now i want to add extra condition like where clause. how to do it.

The requirement given for me is, i have to list proposal which is created by logged in user. I have to add this condition in back end without user knowledge.

I heard about filter. Which filter is correct?how to apply that.Give me an sample. this evening i have demo. help me.


回答1:


First, you need to ensure that the user id is being added to the document in the index in a field when you index, let's call it user_id.

In a pinch, you can add a field to the query string entered by the user behind the scenes before you send it to the query parser. So, take whatever query was entered and add " AND user_id:4" (where 4 is the value of the variable containing the current user id) onto the end of it.



来源:https://stackoverflow.com/questions/1878758/filters-in-lucene

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