简体   繁体   English

Solr 搜索没有给出单个词项的准确结果

[英]Solr search not giving exact result for single word term

I am a very beginner in solr search queries where I am trying to get exact results for my given term.我是 solr 搜索查询的初学者,我试图获得给定术语的准确结果。 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.我要求精确搜索单个单词。

For ex前任

  1. If I search "ship to add" I get result ship to address如果我搜索“发货到添加”,我会得到结果发货到地址

  2. 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植物:我得到植物编号、植物类型、植物描述等结果,然后是植物我想要我的确切词植物首先出现然后我想要其他相关搜索

Approaches I have tried我尝试过的方法

/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

Any help will be appreciated.任何帮助将不胜感激。

You need to use the string as fieldtype for your field name .您需要使用的string作为fieldtype为你的领域name

Apply the String as fieldtype and reindex the data.应用字符串作为fieldtype并重新索引数据。

<field name="name" type="string" indexed="true" stored="true" required="true" multiValued="false" />

String stores the word/sentence as an exact string without performing any tokenization on it. String将单词/句子存储为一个精确的字符串,而不对其进行任何标记化。 Its useful in cases for storing exact matches, eg, for faceting, sorting.它在存储精确匹配的情况下很有用,例如,用于分面、排序。

Opposite of string type is text .string类型相反的是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. Text对数据进行标记化,执行诸如小写等处理。这在我们想要匹配句子的一部分时很有帮助。

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"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM