2017-07-28 40 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