Skip to main content
Known Participant
December 4, 2018
Question

Solr default operator woes on CF2018

  • December 4, 2018
  • 3 replies
  • 1109 views

I am not having any success in changing the Solr defaultOperator to AND so that searches are more like web searches.  If I add an AND between words in my search form, I get what I want.  Without the AND it defaults to OR.

I've changed the defaultOperator  parameter in all the schema.xml files I could find:

\ColdFusion2018\cfusion\jetty\solr\conf\schema.xml

\ColdFusion2018\cfusion\jetty\multicore\collections\CollectionName\conf\schema.xml

I also tried deleting and rebuilding all the collections once the changes to the \ColdFusion2018\cfusion\jetty\solr\conf\schema.xml were made without any joy.  The schema.xml files for each collection had the default set as desired after being deleted and rebuilt, but it still doesn't work right. My recollection is that I had to do this to get the default operator to work right in CF10. 

I'm not seeing any documented changes to <cfsearch> or <cfindex> that should affect this. Ideas anyone?

    This topic has been closed for replies.

    3 replies

    Known Participant
    February 17, 2020

    This drove me nuts for quite a while.  What finally worked for me was to change the parser type parameter to type="DisMax" (the default is "Standard").  I left the defaultOperator parameters set to "AND" and it worked with DisMax. The defaultOperator parameter appears to be deprecated, so I don't know if that made any difference.

    Participant
    April 7, 2021

    Your reply looks so promising since I am having the same problem. I just want the default operator to be AND and not an OR for every search. I set the defaultOperator to AND (makes no difference) and set the mm to 100% (<str name="mm">100%</str>) and still no difference.

     

    Your comment ("What finally worked for me was to change the parser type parameter to type="DisMax" (the default is "Standard"). ") intrigued me but I can't figure out where in the solrconfig.xml to change it. The closest I could find was this line but changing it gave me errors. Can you provide more info? Thank you.

     

    <requestHandler name="standard" class="solr.StandardRequestHandler" default="true">
    <!-- default values for query parameters -->
    <lst name="defaults">
    <str name="echoParams">explicit</str>
    <str name="hl.fl">summary title </str>
    <str name="df">contents</str>
    <!-- omp = Only More Popular -->
    <str name="spellcheck.onlyMorePopular">false</str>
    <!-- exr = Extended Results -->
    <str name="spellcheck.extendedResults">false</str>
    <!-- The number of suggestions to return -->
    <str name="spellcheck.count">1</str>
    <str name="mm">100%</str>
    </lst>
    <arr name="last-components">
    <str>spellcheck</str>
    </arr>
    </requestHandler>


    <!-- StandardRequestHandler allows easy searching across multiple fields
    for simple user-entered phrases.
    see http://wiki.apache.org/solr/StandardRequestHandler
    -->
    <requestHandler name="dismax" class="solr.SearchHandler" >
    <lst name="defaults">
    <str name="echoParams">explicit</str>
    <str name="defType">dismax</str>
    <float name="tie">0.01</float>
    <str name="qf">
    mime^1.0 uid^1.2 key^1.5 title^8.0 contents^10.0
    </str>
    <str name="pf">
    mime^1.0 uid^1.2 key^1.5 title^8.0 contents^10.0
    </str>
    <str name="fl">
    key,uid,url,title,mime,size
    </str>
     <str name="mm">
    2&lt;-1 5&lt;-2 6&lt;90%
    </str>
    <int name="ps">100</int>
    <str name="q.alt">*:*</str>
    <!-- example highlighter config, enable per-query with hl=true -->
    <str name="hl.fl">summary title </str>
    </lst>
    </requestHandler>

    Participant
    April 8, 2021

    Well now I wish I'd written more down because I'm not sure where that setting is now.  I think it is in:

    \ColdFusion2018\cfusion\jetty\solr\conf\solrconfig.xml

     

    This is what my file looks like for the 'requestHandler' section. Hope it helps.

     

    <!-- requestHandler plugins... incoming queries will be dispatched to the
    correct handler based on the path or the qt (query type) param.
    Names starting with a '/' are accessed with the a path equal to the
    registered name. Names without a leading '/' are accessed with:
    http://host/app/select?qt=name
    If no qt is defined, the requestHandler that declares default="true"
    will be used.
    -->
    <requestHandler name="standard" class="solr.SearchHandler" default="true">
    <!-- default values for query parameters -->
    <lst name="defaults">
    <str name="echoParams">explicit</str>
    <!--
    <int name="rows">10</int>
    <str name="fl">*</str>
    <str name="version">2.1</str>
    -->
    </lst>
    </requestHandler>

    <!-- Please refer to http://wiki.apache.org/solr/SolrReplication for details on configuring replication -->
    <!--Master config-->
    <!--
    <requestHandler name="/replication" class="solr.ReplicationHandler" >
    <lst name="master">
    <str name="replicateAfter">commit</str>
    <str name="confFiles">schema.xml,stopwords.txt</str>
    </lst>
    </requestHandler>
    -->
    <!-- Slave config-->
    <!--
    <requestHandler name="/replication" class="solr.ReplicationHandler">
    <lst name="slave">
    <str name="masterUrl">http://localhost:8983/solr/replication</str>
    <str name="pollInterval">00:00:60</str>
    </lst>
    </requestHandler>
    -->

    <!-- DisMaxRequestHandler allows easy searching across multiple fields
    for simple user-entered phrases. It's implementation is now
    just the standard SearchHandler with a default query type
    of "dismax".
    see http://wiki.apache.org/solr/DisMaxRequestHandler
    -->
    <requestHandler name="dismax" class="solr.SearchHandler" >
    <lst name="defaults">
    <str name="defType">dismax</str>
    <str name="echoParams">explicit</str>
    <float name="tie">0.01</float>
    <str name="qf">
    text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
    </str>
    <str name="pf">
    text^0.2 features^1.1 name^1.5 manu^1.4 manu_exact^1.9
    </str>
    <str name="bf">
    ord(popularity)^0.5 recip(rord(price),1,1000,1000)^0.3
    </str>
    <str name="fl">
    id,name,price,score
    </str>
    <str name="mm">
    2&lt;-1 5&lt;-2 6&lt;90%
    </str>
    <int name="ps">100</int>
    <str name="q.alt">*:*</str>
    <!-- example highlighter config, enable per-query with hl=true -->
    <str name="hl.fl">text features name</str>
    <!-- for this field, we want no fragmenting, just highlighting -->
    <str name="f.name.hl.fragsize">0</str>
    <!-- instructs Solr to return the field itself if no query terms are
    found -->
    <str name="f.name.hl.alternateField">name</str>
    <str name="f.text.hl.fragmenter">regex</str> <!-- defined below -->
    </lst>
    </requestHandler>

    Known Participant
    January 24, 2019

    This is still a problem for me (the OP).  The DisMax Query Parser in Solr has a bunch of settings (see The DisMax Query Parser | Apache Solr Reference Guide 6.6 ).  The default for 'mm' or 'minimum should match' parameter looks like this in the ACF 2018 solrconfig.xml file:

      <str name="mm">

            2&lt;-1 5&lt;-2 6&lt;90%

      </str>

    I tried changing this to:

      <str name="mm">

            100%

      </str>

    I restarted CF, but still no change in how the default operator works.

    WolfShade
    Legend
    December 4, 2018

    The only thing that I can think of would be to alter the search value when submitted.  Replace spaces with a space and a plus sign, to force the AND to be used.

    I'm staying away from any CF after CF11.  Once CF11 is EOL, I'm planning on switching to Lucee.

    HTH,

    ^ _ ^

    Known Participant
    December 4, 2018

    Yeah, I thought of doing something like that, but then my colleagues and users will ask "what are all these ANDs about, and why doesn't it just work like Google the way it did before".