2017-07-28 48 views
0

I指數維基百科轉儲文件,這種格式SOLR:如何使用solr來計算節點的網頁排名?

<page> 
    <title>Bruce Willis</title> 
    <ns>0</ns> 
    <id>64673</id> 
    <revision> 
     <id>789709463</id> 
     <parentid>789690745</parentid> 
     <timestamp>2017-07-09T02:27:39Z</timestamp> 
     <contributor> 
     <username>Materialscientist</username> 
     <id>7852030</id> 
     </contributor> 
     <comment>imdb is not a reliable source</comment> 
     <model>wikitext</model> 
     <format>text/x-wiki</format> 
     <text xml:space="preserve" bytes="57375">{{Use mdy dates|date=March 2012}} 
{{Infobox person 
| name = Bruce Willis 
| image = Bruce Willis by Gage Skidmore.jpg 
| caption = Willis at the 2010 [[San Diego Comic-Con]]. 
| birth_name = Walter Bruce Willis 
| birth_date = {{Birth date and age|1955|3|19}} 
| 
| birth_place = [[Idar-Oberstein]], West Germany 
| nationality = [[American people|American]] 
| residence = [[Los Angeles]], [[California]], U.S. 

和核心架構文件:

<fieldType name="string" class="solr.StrField"/> 
    <fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/> 
    <fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/> 
    <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/> 
    <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/> 
    <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/> 

    <field name="id" type="string" indexed="true" stored="true" required="true"/> 
    <field name="_version_" type="long" indexed="true" stored="true"/> 
    <field name="TITLE" type="text_wiki" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" /> 
    <field name="REVISION_TEXT" type="text_wiki" indexed="true" stored="true" multiValued="true" termVectors="true" termPositions="true" termOffsets="true" /> 
    <field name="REVISION_TIMESTAMP" type="date" indexed="true" stored="true" multiValued="true" /> 
    <field name="CONTRIBUTOR_ID" type="int" indexed="true" stored="true" multiValued="true" /> 
    <field name="CONTRIBUTOR_USERNAME" type="string" indexed="true" docValues="true" stored="true" multiValued="true" /> 

    <dynamicField name="*" type="string" indexed="true" stored="true" multiValued="true"/> 
    <uniqueKey>id</uniqueKey> 

我沒有張貼schema.xml中的所有內容。我知道我們可以使用solr來獲得分數或相似性。基於(freq *(k1 + 1))/(freq + k1 *(1-b + b * fieldLength/avgFieldLength))計算相似度。我認爲頁面排名是基於傳入和傳出頁面的數量。但是,對於這個字段,我無法檢索傳入和傳出頁面。

所以我不知道如何使用solr來計算pagerank。我明白錯了嗎?如果你知道如何做到這一點,你能給我一些建議嗎?謝謝

回答

0

取決於你想要的pagerank是多麼先進。如果您只想考慮入站鏈接的數量,則可以通過提取索引時頁面鏈接的頁面列表來計算它。然後,您遍歷存儲的頁面並選擇鏈接到正在查看的頁面的文檔的數量,並使用鏈接到該頁面的文檔數量來存儲新字段。按此分數排序(或將其用於提升等)以影響返回結果的列表。

+0

謝謝。但是,你能告訴我如何提取索引時頁面鏈接的頁面列表。因爲我需要的僅僅是維基百科頁面,而在一個網頁中還有許多其他鏈接,例如文章或新聞。例如, – Cocoa3338

+0

[link](https://en.wikipedia.org/wiki/Bruce_Willis)我需要跳轉到另一個wikipedia頁面的鏈接。例如,「Emma Heming」。但不是「布魯斯威利斯艾美獎得主」(在頁面底部) – Cocoa3338

+0

這將取決於維基百科的標記,但是IIRC,您可以使用'[[]]'內的任何內容來表示與該頁面的鏈接名稱? '[[Idar-Oberstein]]'鏈接到「Idar-Oberstein」頁面。維基百科標記使用'|'在頁面名稱後面提供一個可讀的名稱,但它是'|'前面的部分,對檢測鏈接很有幫助。 – MatsLindh