SOLR exact match results not matching

安稳与你 提交于 2020-02-05 04:26:06

问题


Hi I have a text_exact fieldType (field is text_ex) that has KeywordTokenizerFactory for matching against exact queries. For example, searching for sale gives results that contain the term sale, specifically. When I run the query like this text_ex:sale, the number of results were found to be 28, where as when I run the same query using a switch-query parser (defined in request handler), I get the number of results as 18, even though the parsed query is same as text_ex:sale in the switch query fq. Can anyone help me debug this issue? I suppose there is some inconsistency in the the way the query is parsed for exact case being true or false. I am not sure.

Here is my schema definition:

<fieldType name="text_exact" class="solr.TextField" omitNorms="false">
    <analyzer type="index" omitTermFreqAndPositions="false">  
        <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-FoldToASCII.txt"/>
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory" />    
        <filter class="solr.WordDelimiterGraphFilterFactory"
            generateWordParts="1"
            generateNumberParts="0"
            catenateWords="0"
            catenateNumbers="0"
            catenateAll="1"
            splitOnCaseChange="0"
            splitOnNumerics="0"/>
    </analyzer> 
    <analyzer type="query"> 
        <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-FoldToASCII.txt"/>
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory" /> 
        <filter class="solr.WordDelimiterGraphFilterFactory"
            generateWordParts="0"
            generateNumberParts="0"
            catenateWords="0"
            catenateNumbers="0"
            catenateAll="1"
            splitOnCaseChange="0"
            splitOnNumerics="0"/>
    </analyzer> 
</fieldType>

And here is my solrconfig.xml details:

<requestHandler name="/select" class="solr.SearchHandler">
    <!-- default values for query parameters can be specified, these
         will be overridden by parameters in the request
      -->
    <lst name="defaults">
      <str name="exact">false</str>
      <str name="echoParams">explicit</str>
      <int name="rows">10</int>
      <str name="defType">edismax</str>
      <str name="qf">
        displayValue^20 description^5 connectorName_txt zenDescription_txt^5 zenBusinessOwner_txt^2 
        categoryName^8 reportOwner^2 reportDetailsNameColumn^5 
      </str>
      <str name="pf2">
        displayValue^20 description^5 connectorName_txt zenDescription_txt^5 zenBusinessOwner_txt^2 
        categoryName^8 reportOwner^2 reportDetailsNameColumn^5 
      </str>
      <str name="pf3">
        displayValue^20 description^5 connectorName_txt zenDescription_txt^5 zenBusinessOwner_txt^2 
        categoryName^8 reportOwner^2 reportDetailsNameColumn^5 
      </str>
      <str name="tie">1</str>
      <str name="mm">100%</str>
      <int name="ps2">3</int>
      <int name="ps3">9</int>
      <int name="qs">0</int>
      <str name="df">text</str>
      <str name="q.alt">*:*</str>
      <str name="sort">score desc, averageRating desc, lastOneWeekCount desc</str>
      <str name="bq">
        query({!boost b=20}approved:"yes")
      </str>
    </lst>
    <lst name="appends">
      <str name="fq">{!switch case.false=*:* case.true=text_ex:$${q} v=$exact}</str>
    </lst>
</requestHandler>

And here is the parsed query when I did exact search using the request handler:

"filter_queries":["{!switch case.false=\"*:*\" case.true=\"text_ex:sale\" v=$exact}"],
 "parsed_filter_queries":["text_ex:sale"]

And here is the parsed query when the query text_ex:sale is run:

"filter_queries": [
      "{!switch case.false=\"*:*\" case.true=\"text_ex:text_ex:sale\" v=$exact}"
    ],
    "parsed_filter_queries": [
      "MatchAllDocsQuery(*:*)"
    ]

Also I have noticed that enclosing a query within double quotes is throwing a syntax error. Any suggestions on how to resolve this issue?. Thanks in advance.

Here is the error message:

"error": { "msg": "org.apache.solr.search.SyntaxError: Expected identifier at pos 53 str='{!switch case.false=\"*:*\" case.true=\"text_ex:text_ex\":sale\"\" v=$exact}'", "code": 400 }

来源:https://stackoverflow.com/questions/59931921/solr-exact-match-results-not-matching

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!