如何强制执行完全匹配以获取最高优先级? [英] How to enforce an exact match to get the highest priority?

查看:135
本文介绍了如何强制执行完全匹配以获取最高优先级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在索引和搜索5个字段,它们以各种方式被标记/过滤.
但是,我希望在搜索时,如果输入的查询与字段1中的值匹配,它将是返回的最高结果.
我将如何定义:

I am indexing and searching 5 fields, which are tokenized/filtered in various ways.
BUT, I would like that when I search, if the query I entered matches a value in field 1, it will be the top result I get back.
How would I define:

  1. 领域
  2. 以100%匹配的方式使该字段具有优先级的查询

在我的模式中,我有一个字段

In my schema, I have the field

<field name="na_title" type="text_names" indexed="true" stored="false" required="true" />

text_names是:<fieldType name="text_names" class="solr.StrField" />

text_names is :<fieldType name="text_names" class="solr.StrField" />

我只有条目,其中na_title ="somthing发生在这里".但是,当我搜索 text_names:somthing is going on here我得到很多结果.
只是指出这一点,该字段上没有用于查询和索引操作的分析器或过滤器.

I have ONLY one entry with na_title="somthing is going on here". But, when I search text_names:somthing is going on here I get many results.
Just to point it out, there are no analyzers nor filters on that field, both for query and index actions.

推荐答案

您将需要对该字段建立两次索引-分析一次,然后一次不索引.然后,您可以提高未分析字段中的匹配项.

You'll need to index the field twice -- once analyzed and once not. Then you can boost the matches in the nonanalyzed fields over the others.

一种快捷方式可能是将所有这些字段都索引为字符串,并使用copyfield将它们作为文本复制到一个包罗万象的字段中.这样可以稍微简化查询并减少重复字段的数量.

A shortcut could be to index all those fields as strings and use copyfield to copy them as text into a catch-all field. That would simplify the query a little and decrease the number of duplicate fields.

这篇关于如何强制执行完全匹配以获取最高优先级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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