Filters in Lucene

2019-08-19 07:30发布

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.

标签: lucene
1条回答
仙女界的扛把子
2楼-- · 2019-08-19 07:50

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.

查看更多
登录 后发表回答