首页 文章

Solr不搜索(动态创建)字段

提问于
浏览
1

我已将文档导入Solr,其中包含从模式动态创建的字段(主要是* _s) . 在后端(/ solr / admin),我可以看到它们存在:聚合统计数据,如术语频率,正确显示 . 它们都被列为索引和存储 .

但是,即使我在所有字段中搜索,它们也不会出现在查询中,例如:

/solr/select/?indent=on&q=myterms&fl=*

这个问题似乎与SOLR not searching on certain fields类似,我尝试了那里的解决方案,它是:

如果您希望标准查询处理程序搜索所有字段,您可以在solrconfig.xml中更改它(我总是添加第二个查询处理程序而不是修改“标准”.fl字段是您要搜索的字段列表它是逗号分隔的列表或* .

我对标准solrconfig.xml进行了更改,但仍然没有结果 .

我尝试创建一个非常简单的文档:

{'id':5, 'name':'foo'}

此查询返回该doc:

/solr/select/?indent=on&q=foo&fl=*

没有结果的查询的整个结果如下:

<response>
−
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">1</int>
−
<lst name="params">
<str name="echoParams">all</str>
<str name="h1">true</str>
<str name="defType">dismax</str>
<str name="indent">on</str>
<str name="start">0</str>
<str name="q">Foo</str>
<str name="version">2.2</str>
<str name="rows">10</str>
</lst>
</lst>
<result name="response" numFound="0" start="0"/>
</response>

3 回答

  • 2

    您的“标准”查询处理程序的deftype是dismax吗?如果没有,那么它将无法工作 . 作为您提供的问题的答案,您必须使用dismax在多个字段中进行搜索 . 如果您不想使用dismax但仍希望一次搜索多个字段,则必须在索引时使用复制字段功能将要搜索的所有字段收集到一个字段中,然后将该字段设置为默认字段 .

  • 2

    由于您正在使用 _s ,您可以将这些字段复制到 solr/collection1/conf/schema.xml 中的"text",如下所示:

    <copyField source="*_s" dest="text" maxChars="3000"/>
    

    这是Why do dynamic fields not act like normal fields (specifically when querying and displaying in Hue) in solr?解决方案的一个细微变化,即取消注释 *_t 行:

    <!-- Above, multiple source fields are copied to the [text] field. 
           Another way to map multiple source fields to the same 
           destination field is to use the dynamic field syntax. 
           copyField also supports a maxChars to copy setting.  -->
    
    <!-- <copyField source="*_t" dest="text" maxChars="3000"/> -->
    

    这使得我的动态字段可以搜索到:

    curl http://localhost:8983/solr/collection1/select?q=foo
    

    这是描述"catchall" text 字段的位置:

    <!-- catchall field, containing all other searchable text fields (implemented
         via copyField further on in this schema  -->
    <field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>
    

    另见http://wiki.apache.org/solr/SchemaXml#Copy_Fields

  • 0

    我看到你使用查询"Foo"而 name 值是"foo" . 您可能想要检查de index中的lowercase个术语,并在模式中查询您正在使用的字段类型 name .

相关问题