Lucene中的过滤器 [英] Filters in Lucene

查看:103
本文介绍了Lucene中的过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友

我是Lucene全文搜索的新手.我已经开发了带有全文搜索的页面.它工作正常.但现在我想添加诸如where子句之类的额外条件.怎么做.

给我的要求是,我必须列出由登录用户创建的提案.我必须在没有用户知识的情况下在后端添加此条件.

我听说过过滤器.哪个过滤器正确?如何应用.请给我一个样品.今天晚上我有演示.帮帮我.

解决方案

首先,您需要确保在建立索引时将用户ID添加到字段中索引中的文档中,我们将其称为user_id.

在紧要关头,您可以将字段添加到用户在幕后输入的查询字符串中,然后再将其发送到查询解析器.因此,无论输入什么查询,都在其末尾添加"AND user_id:4"(其中4是包含当前用户ID的变量的值).

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.

解决方案

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.

这篇关于Lucene中的过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆