Solr搜索未给出单个词项的确切结果 [英] Solr search not giving exact result for single word term
问题描述
我是solr搜索查询的初学者,在这里我试图获取给定术语的准确结果.对于包含多个单词的术语,我得到了确切的结果.但是对于只有一个单词的术语,我没有确切的搜索结果.在投反对票或结束这个问题之前,请考虑一下情况.我要精确搜索单个单词.
I am a very beginner in solr search queries where I am trying to get exact results for my given term. I am getting exact result for terms which have more than one word. But for terms which have only one word I am not getting exact search result. Before down voting or closing this question consider the scenario. I am asking exact search for single word.
例如
-
如果我搜索要添加的船",我得到结果要发送的地址
植物:我得到诸如植物编号,植物类型,植物描述之类的结果,然后得到植物我希望我的确切单词Plant首先出现,然后我希望其他相关搜索出现
Plant: I get results like Plant Number, Plant Type, Plant description,and then Plant I want my Exact word Plant to come first then I want other related searches to come
我尝试过的方法
/query?q=(name:"PLant")&stopwords=true //giving output I mentiond above
/query?q=(name:"^PLant$")&stopwords=true //not giving any output
/query?q="PLant"&stopwords=true //giving fuzzy output
任何帮助将不胜感激.
推荐答案
您需要使用 string
作为字段 name
的 fieldtype
将字符串应用为 fieldtype
并重新索引数据.
Apply the String as fieldtype
and reindex the data.
<field name="name" type="string" indexed="true" stored="true" required="true" multiValued="false" />
String
将单词/句子存储为精确的字符串,而不对其进行任何标记化.在存储精确匹配的情况下(例如,刻面,排序)有用.
String
stores the word/sentence as an exact string without performing any tokenization on it.
Its useful in cases for storing exact matches, e.g, for faceting, sorting.
与 string
类型相反的是 text
. Text
对数据进行标记化,执行诸如小写字母等处理.在我们希望匹配句子的一部分时很有用.
Opposite of string
type is text
.
Text
does the tokenization of data, performs processing such as lower-casing etc. It is helpful in case when we want to match part of a sentence.
如果要实现小写搜索,请为您的字段使用以下字段类型.
If you want achieve the lowercase search then use the below fieldtype for you field.
<fieldType name="forExactMatch" class="solr.TextField" sortMissingLast="true" omitNorms="true">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>
然后您的场定义将如下所示
Then your field defination will look like below
<field name="name" type="forExactMatch" indexed="true" stored="true"/>
这篇关于Solr搜索未给出单个词项的确切结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!