首页 > 解决方案 > 在 Solr 中对字段进行精确搜索

问题描述

我想完全匹配我收藏中的一个字段(域)。现在,如果我搜索“DIU”,它会给我带来“DIU”和“DIU/DRRU”,我只需要“DIU”。当我搜索“DIU/DRRU”时,我只需要“DIU/DRRU”。我怎样才能做到这一点?我正在使用 Solr 7.4

我的架构设置是 -

"name":"domain",
        "type":"text_general",
        "multiValued":false,
        "indexed":true,
        "stored":true},

{
        "name":"text_general",
        "class":"solr.TextField",
        "positionIncrementGap":"100",
        "multiValued":true,
        "indexAnalyzer":{
          "tokenizer":{
            "class":"solr.StandardTokenizerFactory"},
          "filters":[{
              "class":"solr.StopFilterFactory",
              "words":"stopwords.txt",
              "ignoreCase":"true"},
            {
              "class":"solr.LowerCaseFilterFactory"}]},
        "queryAnalyzer":{
          "tokenizer":{
            "class":"solr.StandardTokenizerFactory"},
          "filters":[{
              "class":"solr.StopFilterFactory",
              "words":"stopwords.txt",
              "ignoreCase":"true"},
            {
              "class":"solr.SynonymGraphFilterFactory",
              "expand":"true",
              "ignoreCase":"true",
              "synonyms":"synonyms.txt"},
            {
              "class":"solr.LowerCaseFilterFactory"}]}},

标签: solr

解决方案


使用字符串字段而不是text_general基于字段 -text_general字段(附加了 StandardTokenizer)将在/. 只有当string字段与存储的值完全匹配时,该字段才会给出匹配。


推荐阅读