solrfull-text-searchdismax

Solr dismax query returns no data, while standard query does


I am unable to find any result when calling query like that:

http://localhost:8983/solr/somecore/select?q=title:king&wt=json&defType=dismax

But calling query like this:

http://localhost:8983/solr/somecore/select?q=title:king&wt=json

Finds as expected 9 documents.

I tried various things (like for example qildcard: :, to no avail).

If anyone could point me to problem or documentation that may explain me what I am doing wrong.

If it's matters, schema.xml is as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<schema name="example" version="0.1">
<types>
    <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
    <fieldType name="bool" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
    <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true" />
    <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
    <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" omitNorms="true" positionIncrementGap="0" />
    <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate" />
    <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
    <fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>
    <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
    <fieldType name="random" class="solr.RandomSortField" />
    <fieldType name="binary" class="solr.BinaryField" />

    <fieldType name="text" class="solr.TextField" positionIncrementGap="100">
      <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
        <filter class="solr.WordDelimiterFilterFactory" splitOnNumerics="1" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
        <filter class="solr.WordDelimiterFilterFactory" splitOnNumerics="1" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
      </analyzer>
    </fieldType>
</types>

<fields>
    <!-- required -->
    <field name="uid" type="string" indexed="true" stored="true" required="true" multiValued="false" />
    <field name="doc_type" type="string" indexed="true" stored="true" required="true" multiValued="false" />
    <field name="title" type="text" indexed="true" stored="true" required="true" multiValued="false" termVectors="true" />

    <!-- optionals -->
    <field name="status" type="string" indexed="true" stored="true" required="false" multiValued="false" />
    <field name="created_at" type="tdate" indexed="true" stored="true" required="false" multiValued="false" />
    <field name="updated_at" type="tdate" indexed="true" stored="true" required="false" multiValued="false" />
    <field name="tags" type="string" indexed="true" stored="true" required="false" multiValued="true" />
    <field name="body" type="text" indexed="false" stored="true" required="false" multiValued="false" termVectors="false" />
    <field name="is_active" type="bool" indexed="true" stored="true" required="false" multiValued="false" />

    <!-- dynamic fields: they get a dyn_ prefix, then a type, then a wildcard -->
    <dynamicField name="dyn_text_*" type="text" indexed="true"  stored="true" multiValued="false" />
    <dynamicField name="dyn_string_*" type="string" indexed="true"  stored="true" multiValued="false" />
    <dynamicField name="dyn_bool_*" type="bool" indexed="true"  stored="true" multiValued="false" />
    <dynamicField name="dyn_int_*" type="int" indexed="true"  stored="true" multiValued="false" />

    <field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
</fields>

<uniqueKey>uid</uniqueKey>
<defaultSearchField>title</defaultSearchField>
<solrQueryParser defaultOperator="OR"/>
</schema>

Solution

  • Got solution, for some unknown to me reason, q=king is not going work unless we define which field should be used for filtering, in my case:

    http://localhost:8983/solr/somecore/select?q=king&wt=json&defType=dismax&qf=title+body
    

    PS

    Of course "title:" should be omitted as well. I did not mention it in original question, but I tried with and without it in query.