0

我正在努力让 solr 与我的组织合作。它在 tomcat 6 上设置为多核 solr 3.6。

到目前为止,我已经修改了示例 schema.xml 以接受我们记录的特定字段。记录没有问题,当我对所有记录 ( ?q=*:*) 运行查询时,它会返回所有内容。但是当我查询绝对在记录中的特定术语时(例如?q=greenor ?q=product_description:green),没有结果出现。虽然如果我插入一些默认示例文档,如 ipod_video.xml 或 ipod_other.xml,但如果搜索它们(例如?q=ipod?q=video) ,这些记录确实会出现

我们所有的新字段都是用indexed=true它们定义的,所以我不确定为什么如果我们查询它们,我们自己的记录根本不会出现。

任何想法如何调试这种行为?

更新- 添加 schema.xml 和 solrconfig.xml 详细信息。

schema.xml 与 solr 3.6 附带的默认 schema.xml 几乎相同,但添加了以下字段

<fields>
<field name="search_title" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="search_prefix" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="search_description" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="search_content" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="product_date" type="date" indexed="true" stored="true" multiValued="true"/>
<field name="product_thumbnail" type="string" indexed="true" stored="true" multiValued="true"/>

<field name="product_type" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="product_updatepricefunction" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="tagids" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="tagid" type="string" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_tag" type="string" indexed="true" stored="true"/>
<field name="event_id" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="activity_id" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="activity_function_code" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="search_room" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="weekday" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="activity_weekday" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="activity_begindate" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="activity_begintime" type="string" indexed="true" stored="true"  multiValued="true"/>
<field name="activity_endtime" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="audience" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="format" type="text_general" indexed="true" stored="true"   multiValued="true"/>
<field name="publish_date" type="date" indexed="true" stored="true" multiValued="true"/>
<field name="isbn" type="string" indexed="true" stored="true" multiValued="true" />
<field name="product_code" type="string" indexed="true" stored="true" required="true"/>
</fields>

<uniqueKey>product_code</uniqueKey>

这是来自 solrconfig.xml 的请求处理程序

<requestHandler name="/select" class="solr.SearchHandler">
<!-- default values for query parameters can be specified, these
     will be overridden by parameters in the request
  -->
 <lst name="defaults">
   <str name="echoParams">explicit</str>
   <int name="rows">10</int>
   <str name="df">text</str>
 </lst>
<!-- In addition to defaults, "appends" params can be specified
     to identify values which should be appended to the list of
     multi-val params from the query (or the existing "defaults").
  -->
<!-- In this example, the param "fq=instock:true" would be appended to
     any query time fq params the user may specify, as a mechanism for
     partitioning the index, independent of any user selected filtering
     that may also be desired (perhaps as a result of faceted searching).

     NOTE: there is *absolutely* nothing a client can do to prevent these
     "appends" values from being used, so don't use this mechanism
     unless you are sure you always want it.
  -->
<!--
   <lst name="appends">
     <str name="fq">inStock:true</str>
   </lst>
  -->
<!-- "invariants" are a way of letting the Solr maintainer lock down
     the options available to Solr clients.  Any params values
     specified here are used regardless of what values may be specified
     in either the query, the "defaults", or the "appends" params.

     In this example, the facet.field and facet.query params would
     be fixed, limiting the facets clients can use.  Faceting is
     not turned on by default - but if the client does specify
     facet=true in the request, these are the only facets they
     will be able to see counts for; regardless of what other
     facet.field or facet.query params they may specify.

     NOTE: there is *absolutely* nothing a client can do to prevent these
     "invariants" values from being used, so don't use this mechanism
     unless you are sure you always want it.
  -->
<!--
   <lst name="invariants">
     <str name="facet.field">cat</str>
     <str name="facet.field">manu_exact</str>
     <str name="facet.query">price:[* TO 500]</str>
     <str name="facet.query">price:[500 TO *]</str>
   </lst>
  -->
<!-- If the default list of SearchComponents is not desired, that
     list can either be overridden completely, or components can be
     prepended or appended to the default list.  (see below)
  -->
<!--
   <arr name="components">
     <str>nameOfCustomComponent1</str>
     <str>nameOfCustomComponent2</str>
   </arr>
  -->
</requestHandler>
4

1 回答 1

1

一种q=<search phrase>方法,从提到的默认字段中搜索。但是,如果您没有指定默认字段,或者您想查询除默认字段以外的特定字段,您应该查询 Solr,如q=<fieldname>:<search phrase>.

Solr 提供了多种分析器,您可以根据需要使用这些分析器来索引文档。看看这里

问题更新后编辑

1st -/select requestHandler具有默认字段text,并且您的 schema.xml 文件没有名为 text 的字段。

第二 - 在您的 schema.xml 文件中,字段、 、search_titlesearch_description是标记化的类型。所有其他字段都是 type 。search_contentaudienceformattext_generalString

3rd - 要在 type 字段中搜索String,您需要有准确的搜索短语,或者您需要使用通配符。例如,如果您的文档greenproduct_type 字段中具有值,那么查询q=product_type:green将在搜索结果中为您提供文档。但是,如果您green colorproduct_type字段中有值,则查询q=product_type:green将不会提供任何输出。但是查询q=product_type:green*会在搜索结果中为您提供一个文档。

我想我已经为您提供了一个良好的开端和有关 Solr 的基本信息。您现在应该继续阅读我上面提供的链接。

于 2013-06-19T15:09:58.527 回答