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

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

问题描述

我使用apache Solr搜索我的数据库..



假设我已经从我的表中索引4列.. ..希望只有那些包含我的查询字词 的列会在回复中返回.. .. ..是可能的..



例如:



我有一个汽车列: name,displayName,description ,extra ..

现在我进行查询,例如:

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


b $ b

现在,在某些行中只有 名称 可能包含 b $ b

因此,作为回报,我只想要名称(以及 ID )等其他固定字段。



同样,如果 description 包含此字词,则只应返回 description 。 !!



我如何能够实现这个...

解决方案

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



更新
如何在没有自定义变压器的Solr中执行此操作。为所有四个列启用突出显示:

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

Solr将返回一个包含键和匹配查询的字段。你也会得到突出显示的片段,无论你使用它们是由你。请参阅此处查看其他参数: http://wiki.apache.org/solr/HighlightingParameters p>

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天全站免登陆