Solr-如果在特殊字段中发现查询,则提升结果 [英] Solr - Boosting result if query is found in a special field

查看:55
本文介绍了Solr-如果在特殊字段中发现查询,则提升结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,如果在不使用"fieldname:query"语法的特殊字段中找到查询,Solr 3.4是否有可能提高搜索结果.

I am wondering if it is possible with Solr 3.4 to boost a search result, if the query is found in a special field without using the "fieldname:query"-syntax.

让我解释一下:

我的索引中有几个字段.其中之一被称为缩写",并用诸如AVZ,JSP,DECT,...之类的文本填充.

I have several fields in my index. One of it is named "abbreviation" and is filled with text like AVZ, JSP, DECT, ...

为了能够在纯粹搜索"AVZ"时找到结果,我添加了一个

To be able to find results when searching purely for "AVZ" I added a

<copyField source="abbreviation" dest="text"/>

在我的schema.xml中.文本字段是我的defaultSearchField.

in my schema.xml. The field text is my defaultSearchField.

我认为这不是最好的解决方案.因此,我试图找出是否可以在所有字段中搜索"AVZ",并且如果在字段缩写中找到了字符串",则应增强结果条目(增加分数),以便将其列在结果列表中的第一项.将与使用缩写:AVZ AVZ 作为查询相同.

This is not the best solution in my opinion. So I am trying to find out, if it is possible to search for "AVZ" in all fields and if the String is found in the field abbreviation, the result entry should be boosted (increasing the score) so that it will be listed at first entry in the result list. Would be the same as using abbreviation:AVZ AVZ as query.

我可以想到的另一种可能性是分析查询.并且,如果找到了类似"AVZ"的子字符串,则该查询将附加缩写:AVZ .但是在这种情况下,我必须能够找出索引了哪些缩写.是否可以使用SolrJ从Solr索引中检索字段的所有可能的项?

The other possibility I can think of is to analyze the query. And if a substring like "AVZ" is found, the query will be appended with abbreviation:AVZ. But in this case I must be able to find out, which abbreviations are indexed. Is it possible to retrieve all possible terms of a field from the Solr index using SolrJ?

最好的问候托比亚斯

推荐答案

不使用fieldname:term语法可以定义请求处理程序-

Without the fieldname:term syntax use can define a request handler -

<requestHandler name="search" class="solr.SearchHandler" default="true">
 <lst name="defaults">
   <str name="echoParams">explicit</str>
   <str name="defType">dismax</str>
   <str name="qf">
      abbreviation^2 text
   </str>
   <str name="q.alt">*:*</str>
   <str name="rows">10</str>
   <str name="fl">*,score</str>
 </lst>
</requestHandler>

这使用dismax查询解析器.您也可以使用edismax.
这将提高结果,并且查询将是简单的查询,因为q = AVZ.

This uses the dismax query parser. You can use edismax as well.
This will boost the results and query would be a simple query as q=AVZ.

如果仅通过URL,则可以提高特定字段的匹配度,例如提到的@ 链接

If only through url, you can boost match on specific field like mentioned @ link

例如

q=abbreviation:AVZ^2 text:AVZ

这将通过缩写匹配来增强结果,从而使文档显示在顶部.

This would boost the results with a match on abbreviation, which would result the documents to appear on top.

使用 *:* 查询无法获得dismax的所有结果.
但是,对于所有文档,都不要传递任何q参数. q.alt = *:* 将返回所有文档.

It is not possible to get all results with dismax using the *:* query.
However, for all docs just do not pass any q param. q.alt=*:* will return all the docs.

否则,将 defType 更新为 edismax .

<requestHandler name="search" class="solr.SearchHandler" default="true">
 <lst name="defaults">
   <str name="echoParams">explicit</str>
   <str name="defType">edismax</str>
   <str name="qf">
      abbreviation^2 text
   </str>
   <str name="q.alt">*:*</str>
   <str name="rows">10</str>
   <str name="fl">*,score</str>
 </lst>
</requestHandler>

这篇关于Solr-如果在特殊字段中发现查询,则提升结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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