[英]How to debug solr query not returning records
我正在努力使solr與我的組織合作。 它在tomcat 6上設置為多核solr 3.6。
到目前為止,我已經修改了示例schema.xml以接受記錄的特定字段。 記錄沒有問題,當我查詢所有記錄( ?q=*:*
)時,它將返回所有內容。 但是,當我查詢絕對在記錄中的特定術語時(例如?q=green
或?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>
q=<search phrase>
表示從提到的默認字段進行搜索。 但是,如果您未指定默認字段,或者要查詢除默認字段以外的特定字段,則應查詢Solr,例如q=<fieldname>:<search phrase>
。
Solr提供了各種分析器,您可以根據需要使用它們來為文檔建立索引。 在這里看看。
問題更新后編輯
requestHandler
/select
requestHandler
具有默認的字段text
,而您的schema.xml文件沒有名為text的字段。
第二-在您的schema.xml文件中,字段search_title
, search_description
, search_content
, audience
和format
為text_general
類型,這是標記化的。 其他所有字段均為String
類型。
3rd-要在String
類型的字段中進行搜索,您需要具有確切的搜索詞組,或者需要使用通配符。 例如,如果您的文檔在product_type
字段中具有green
值,則查詢q=product_type:green
將為您提供搜索結果中的文檔。 但是,如果在product_type
字段中具有green color
值,則查詢q=product_type:green
將不會提供任何輸出。 但是查詢q=product_type:green*
會在搜索結果中給您一個文檔。
我想我已經為您提供了很好的開端和有關Solr的基本信息。 現在,您應該繼續閱讀上面提供的鏈接。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.