solrsolr4

Solr term search not searching all values from multifields value


I have solr field

<field name="AllTitles" type="text_general" indexed="true" stored="false" multiValued="true"/>

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
    <!-- in this example, we will only use synonyms at query time -->
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>

Example of Value for AllTitles entered is

AllTitles: [ "Anything", "wuhan coronavirus", "anything" ]
AllTitles: [ "wuhan coronavirus", "anything", "anything" ]

It searches from first index but if any matching term on index other than 1st then it's not searching

For example when I search

q="wuhan coronavirus"

I get 2 results. When I search using field name "AllTitles"

q=AllTitles:"wuhan coronavirus"

I get 7 results correctly.

Can anybody help me identifying the issue?


Solution

  • First, in your SolrConfig.xml check what field has been defined in the "df". In the below example it is "text".

    <requestHandler name="/select" class="solr.SearchHandler">
       <lst name="defaults">
         <str name="echoParams">explicit</str>
         <int name="rows">10</int>
         <str name="df">text</str>
      </requestHandler>
    

    Second, in the schema.xml or managed-schema, whichever you are using, make sure you have copied "AllTitles" to "text". Like this,

    <copyField source="AllTitles" dest="text"/>
    

    You might as well test it by adding "AllTitles" to your "df" parameter when you query, before doing all these, like raghu777 has mentioned.