在调用这样的查询时,我无法找到任何结果:
http://localhost:8983/solr/somecore/select?q=title:king&wt=json&defType=dismax
但是调用这样的查询:
http://localhost:8983/solr/somecore/select?q=title:king&wt=json
按预期查找9份文件。
我尝试了各种各样的东西(比如qildcard::,但无济于事。)
如果有人能指出我的问题或文件,可能会解释我的错误。
如果重要,schema.xml如下:
<?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>
答案 0 :(得分:0)
得到解决方案,对于一些我不知道的原因,除非我们定义哪个字段应该用于过滤,否则q = king不起作用,在我的情况下:
http://localhost:8983/solr/somecore/select?q=king&wt=json&defType=dismax&qf=title+body
PS
当然“标题:”也应该省略。我没有在原始问题中提及它,但我在查询中尝试使用和不使用它。