简体   繁体   English

如何调试Solr查询不返回记录

[英]How to debug solr query not returning records

I am working to get solr working with my organization. 我正在努力使solr与我的组织合作。 It is setup as multicore solr 3.6 on tomcat 6. 它在tomcat 6上设置为多核solr 3.6。

So far I have modified the sample schema.xml to accept the specific fields for our records. 到目前为止,我已经修改了示例schema.xml以接受记录的特定字段。 Records are going in no problem and when I run a query for all records ( ?q=*:* ) it returns everything. 记录没有问题,当我查询所有记录( ?q=*:* )时,它将返回所有内容。 But when I query for specific terms that are absolutely in the records (eg ?q=green or ?q=product_description:green ), no results come up. 但是,当我查询绝对在记录中的特定术语时(例如?q=green?q=product_description:green ),没有结果出现。 Though if I insert some of the default example docs like ipod_video.xml or ipod_other.xml, those records do come up if it search for them (eg ?q=ipod or ?q=video ) 尽管如果我插入一些默认的示例文档(例如ipod_video.xml或ipod_other.xml),但如果搜索它们,这些记录的确会出现(例如?q=ipod?q=video

All of our new fields are defined with indexed=true on them so I am not sure why our own records are not coming up at all if we query them. 我们所有的新字段都在它们上定义为indexed=true ,因此我不确定为什么如果查询它们根本不会出现我们自己的记录。

Any ideas how to debug this behavior? 任何想法如何调试此行为?

UPDATE - adding schema.xml and solrconfig.xml details. 更新 -添加schema.xml和solrconfig.xml详细信息。

schema.xml is virtually the same as the default schema.xml that comes with solr 3.6 but with these added fields : 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>

and here is the request handler from solrconfig.xml : 这是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>

A q=<search phrase> means, search from the default field that is mentioned. q=<search phrase>表示从提到的默认字段进行搜索。 However, if you have not specified a default field or you want to query a specific field other than the default field you should query Solr like q=<fieldname>:<search phrase> . 但是,如果您未指定默认字段,或者要查询除默认字段以外的特定字段,则应查询Solr,例如q=<fieldname>:<search phrase>

Solr provides a variety of analyzers that you can use to index documents according to your requirement. Solr提供了各种分析器,您可以根据需要使用它们来为文档建立索引。 Have a look here . 在这里看看。

EDIT after question update 问题更新后编辑

1st - The /select requestHandler has the field text as default and you schema.xml file does not have a field named text. requestHandler /select requestHandler具有默认的字段text ,而您的schema.xml文件没有名为text的字段。

2nd - In your schema.xml file the fields search_title , search_description , search_content , audience and format are of type text_general which is tokenized. 第二-在您的schema.xml文件中,字段search_titlesearch_descriptionsearch_contentaudienceformattext_general类型,这是标记化的。 All the other fields are of type String . 其他所有字段均为String类型。

3rd - To search in a field of type String , you need to have the exact search phrase or you need to use wildcards. 3rd-要在String类型的字段中进行搜索,您需要具有确切的搜索词组,或者需要使用通配符。 For eg if your document has the value green in the product_type field then the query q=product_type:green would give you the document in the search result. 例如,如果您的文档在product_type字段中具有green值,则查询q=product_type:green将为您提供搜索结果中的文档。 However if you have the value green color in the product_type field the the query q=product_type:green will not give any output. 但是,如果在product_type字段中具有green color值,则查询q=product_type:green将不会提供任何输出。 But the query q=product_type:green* would give you a document in the search result. 但是查询q=product_type:green*会在搜索结果中给您一个文档。

I think i have given you a head start and the basic information about Solr. 我想我已经为您提供了很好的开端和有关Solr的基本信息。 You should now go ahead and read from the link I provided above. 现在,您应该继续阅读上面提供的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM