W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
TermVectorComponent 是一個搜索組件,用于返回關于與您的搜索匹配的文檔的附加信息。
對于響應中的每個文檔,TermVectorCcomponent 可以返回術語向量、術語頻率、逆文檔頻率、位置和偏移量信息。
TermVectorComponent 未在 Solr 中隱式啟用 - 它必須在 solrconfig.xml 文件中顯式配置。本頁中的示例顯示了如何在 Solr 的 "techproducts" 示例中進行配置:
bin/solr -e techproducts
要啟用這個組件,您需要使用一個 searchComponent 元素來配置它:
<searchComponent name="tvComponent" class="org.apache.solr.handler.component.TermVectorComponent"/>
然后必須將請求處理程序配置為使用此組件名稱。在這個 techproducts 例子中,該組件與一個名為 /tvrh 的特殊請求處理程序相關聯(lián),默認情況下,使用 tv=true 參數(shù)啟用術語向量;但您可以將其與任何請求處理程序關聯(lián):
<requestHandler name="/tvrh" class="org.apache.solr.handler.component.SearchHandler">
<lst name="defaults">
<bool name="tv">true</bool>
</lst>
<arr name="last-components">
<str>tvComponent</str>
</arr>
</requestHandler>
一旦您的處理程序被定義了,您可以和任何模式一起使用(uniqueKeyField)對于用 termVector 屬性配置的字段,例如在 techproducts 示例模式中:
<field name="includes"
type="text_general"
indexed="true"
stored="true"
multiValued="true"
termVectors="true"
termPositions="true"
termOffsets="true" />
下面的例子顯示了使用上面的配置調用這個 TermVectorComponent 組件:
http://localhost:8983/solr/techproducts/tvrh?q=*:*&start=0&rows=10&fl=id,includes&wt=xml
...
<lst name="termVectors">
<lst name="GB18030TEST">
<str name="uniqueKey">GB18030TEST</str>
</lst>
<lst name="EN7800GTX/2DHTV/256M">
<str name="uniqueKey">EN7800GTX/2DHTV/256M</str>
</lst>
<lst name="100-435805">
<str name="uniqueKey">100-435805</str>
</lst>
<lst name="3007WFP">
<str name="uniqueKey">3007WFP</str>
<lst name="includes">
<lst name="cable"/>
<lst name="usb"/>
</lst>
</lst>
<lst name="SOLR1000">
<str name="uniqueKey">SOLR1000</str>
</lst>
<lst name="0579B002">
<str name="uniqueKey">0579B002</str>
</lst>
<lst name="UTF8TEST">
<str name="uniqueKey">UTF8TEST</str>
</lst>
<lst name="9885A004">
<str name="uniqueKey">9885A004</str>
<lst name="includes">
<lst name="32mb"/>
<lst name="av"/>
<lst name="battery"/>
<lst name="cable"/>
<lst name="card"/>
<lst name="sd"/>
<lst name="usb"/>
</lst>
</lst>
<lst name="adata">
<str name="uniqueKey">adata</str>
</lst>
<lst name="apple">
<str name="uniqueKey">apple</str>
</lst>
</lst>
下面的例子顯示了這個組件的一些可用的請求參數(shù):
http://localhost:8983/solr/techproducts/tvrh?q=includes:[* TO *]&rows=10&indent=true&tv=true&tv.tf=true&tv.df=true&tv.positions=true&tv.offsets=true&tv.payloads=true&tv.fl=includes
如果為true
,將運行術語向量組件。
對于給定的以逗號分隔的 Lucene 文檔 ID 列表(不是 Solr 唯一鍵),將返回術語向量。
對于給定的以逗號分隔的字段列表,將返回術語向量。如果未指定,則使用fl
參數(shù)。
如果為true
將啟用以下列出的所有布爾參數(shù):tv.df
,tv.offsets
,tv.positions
,tv.payloads
,tv.tf
和tv.tf_idf
。
如果為true
,將返回集合中該術語的文檔頻率(DF)。這可能在計算上是昂貴的。
如果為true
,將返回文檔中每個術語的偏移信息。
如果為true
,則返回位置信息。
如果為true
,則返回有效載荷信息。
如果為true
,返回文檔中每個術語的文檔術語頻率信息。
如果為true
計算每個術語的 TF/DF(即:TF * IDF)。請注意,這是“ 字頻乘以逆文檔頻率” 的文字計算,而不是經(jīng)典的 TF-IDF 相似性度量。
這個參數(shù)需要tv.tf
和tv.df
是 true。這可能在計算上是昂貴的。(結果不顯示在示例輸出中)
要查看 TermVector 組件輸出的示例,請參閱Wiki頁面:http://wiki.apache.org/solr/TermVectorComponentExampleOptions
SolrQuery 類和 QueryResponse 類都不提供特定的方法調用來設置術語向量組件參數(shù)或獲取 "termVectors" 輸出。但是,它有一個補?。?a rel="external nofollow" target="_blank" style="background-color: rgb(255, 255, 255);">SOLR-949。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: