【问题标题】:How to use solr to calculate the pagerank of a node?如何使用 solr 计算节点的 pagerank?
【发布时间】:2017-07-28 09:37:04
【问题描述】:

我用这种格式将维基百科转储文件索引到 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))。我认为页面排名是基于传入和传出页面的数量。但是使用这个 typeField 我无法检索传入和传出页面。

所以我不知道如何使用 solr 计算 pagerank。我理解错了吗?如果你知道怎么做,你能给我一些建议吗?谢谢

【问题讨论】:

    标签: solr pagerank


    【解决方案1】:

    取决于您希望页面排名达到的高级程度。如果您只想考虑入站链接的数量,您可以通过提取一个页面在索引时链接到的页面列表来计算它。然后,您遍历存储的页面并选择链接到您正在查看的页面的文档数,存储一个新字段,其中包含链接到该页面的文档数。按此分数排序(或将其用于提升等)以影响返回的结果列表。

    【讨论】:

    • 谢谢。但是你能告诉我如何提取索引时页面链接到的页面列表吗?因为我需要的只是维基百科页面,而在一个网页中还有许多其他链接,例如文章或新闻。
    • 例如,link 我需要跳转到另一个维基百科页面的链接。例如,“艾玛赫明”。但不是“布鲁斯威利斯艾美奖得主”(在页面底部)
    • 这将取决于维基百科的标记,但是 IIRC,您可以使用 [[]] 中的任何内容来表示指向具有该名称的页面的链接? [[Idar-Oberstein]] 链接到“Idar-Oberstein”页面。维基百科标记使用| 在页面名称后面提供一个可读的名称,但它是| 前面的部分,这对于检测链接很有趣。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-30
    • 2013-06-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多