• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Solr default operator woes on CF2018

New Here ,
Dec 04, 2018 Dec 04, 2018

Copy link to clipboard

Copied

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?

Views

722

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 04, 2018 Dec 04, 2018

Copy link to clipboard

Copied

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,

^ _ ^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 04, 2018 Dec 04, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 24, 2019 Jan 24, 2019

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 17, 2020 Feb 17, 2020

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 07, 2021 Apr 07, 2021

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2021 Apr 08, 2021

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2021 Apr 08, 2021

Copy link to clipboard

Copied

After struggling, I finally got it to work. In the solrconfig.xml for that particular collection, I added this line <str name="q.op">AND</str> to the "standard" requestHandler and this seems to return the AND search results I expect.

 

I was setting  <solrQueryParser q.op="AND"/> in the schema.xml thinking that was where I was suppose to do it (of course, it made no difference I still got an OR search result).

I also added the mm (Minimum Should Match) Parameter <str name="mm">100%</str> after the <str name="q.op">AND</str>, it doesn't appear to make a difference but I left it in as it is suppose to make a certain minimum number of clauses match.

 

So the "standard" requestHandler looks this:

 

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

<str name="q.op">AND</str>

<str name="mm">100%</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>

</lst>

<arr name="last-components">

<str>spellcheck</str>

</arr>

</requestHandler>

 

If you want to this setting to be the default for future collections, make your modifications under:

 

..CF2018\cfusion\jetty\multicore\template

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2021 Apr 08, 2021

Copy link to clipboard

Copied

LATEST

I couldn't edit my original reply but I wanted to say thank you for your reply. I found the fix and I wrote it in more detail in this thread in case the future us have this same problem again! 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation