如何返回与 Solr 中的查询匹配的列..? [英] How to return column that matched the query in Solr..?

查看:20
本文介绍了如何返回与 Solr 中的查询匹配的列..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 apache Solr 来搜索我的数据库..!!

假设我已经从我的一个表中索引了 4 列..!!..我只是希望只返回那些包含我的查询词的列 作为响应..!!..这可能吗..??

例如:

我有一个表 cars 有列:name, displayName, description, extra ..!!

现在我做一个查询,比如:

localhost:8983/solr/select?q=maruti&wt=json

现在某些行中只有 name 可能包含单词maruti"

所以,作为回报,我只想要 name(以及其他一些固定字段,如 ID)..

同样,如果 description 包含这个词,那么应该只返回 description ......而不是其他列..!!

我怎样才能做到这一点..??

解决方案

您可以使用 Solr 4 和自定义转换器来实现这一点 - 我对文档的阅读似乎表明了这一点.但我认为这将是相当多的工作.最终,您可能需要编写前端过滤器,但这对于复杂的查询来说会很困难.

更新:以下是在没有自定义转换器等的情况下在 Solr 中执行此操作的方法.为所有四列启用突出显示:

hl=on&hl.fl=name,displayName,description,extra

Solr 将返回一个突出显示"结构,其中包含与查询匹配的键和字段.您还将获得突出显示的片段,是否使用它们取决于您.有关其他参数,请参见此处:http://wiki.apache.org/solr/HighlightingParameters>

I am using apache Solr for searching my database..!!

Suppose i have indexed 4 columns from one of my table..!!..I just want that only those columns that contains my query term are returned in response..!!..is that possible..??

For example :

I have a table cars with columns : name, displayName, description, extra ..!!

Now i make a query , something like :

localhost:8983/solr/select?q=maruti&wt=json

Now some in some rows only name may contain the word "maruti"

So, In return, i want only name (along with some other fixed fields like ID) ..

Similarly, If description contains this word, then only description should be returned..and not other columns..!!

How can i acheive this..??

解决方案

You may be able to do this with Solr 4 and a custom transformer - my reading of the documentation would seem to indicate as much. But it would be quite a bit of work, I think. Ultimately you may have to write a front-end filter, but that would be difficult with complex queries.

Update: Here's how to do this in Solr without custom transformers, etc. Enable highlighting for all four columns:

hl=on&hl.fl=name,displayName,description,extra

Solr will return a "highlighting" structure containing the key and the field(s) that match the query. You will also get highlighted snippets, whether you use them is up to you. See here for additional params: http://wiki.apache.org/solr/HighlightingParameters

这篇关于如何返回与 Solr 中的查询匹配的列..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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