2

我是 solr 的新手,我正在尝试建立一个问答系统。我已经索引了一些 Wikipedia 页面,例如 Nikola Tesla。 https://en.wikipedia.org/wiki/Nikola_Tesla

我的问题是:有可能以及如何在 Solr 中输入查询作为问题?

我将维基百科页面按“内容”(对应于 SectionTitle)拆分,所以......对于查询,pageTitle:Nikola Tesla我的结果是:

"response":{"numFound":23,"start":0,"docs":[
{
        "sectionTitle":"First Paragraph",
        "pageTitle":"Nikola Tesla",
        "text":["Born and raised in the Austrian Empire, Tesla received an advanced education in engineering and physics in the 1870s and gained practical experience in the early 1880s working in telephony and at Continental Edison in the new electric power industry.]},
{
        "sectionTitle":"Early years",
        "pageTitle":"Nikola Tesla",
        "text":["Nikola Tesla was born an ethnic Serb in the village Smiljan, Lika county, in the Austrian Empire (present day Croatia), on 10 July [O.S. 28 June] 1856. etc..]}]
  }}

schema的如下:

  <field name="id" type="string" indexed="true" required="true" stored="true"/>
  <field name="pageTitle" type="text_en" indexed="true" stored="true"/>
  <field name="sectionTitle" type="text_en" indexed="true" stored="true"/>
  <field name="title" type="text_en" indexed="true" stored="true"/>
  <field name="text" type="text_general" indexed="true" stored="true"/>

是否可以将查询键入为问题?以及如何显示与问题相似的结果? 例如,看上面...

如何键入查询When Nikola Tesla born?并获取段落

"sectionTitle":"Early years",
"pageTitle":"Nikola Tesla",
"text":["Nikola Tesla was born an ethnic Serb in the village Smiljan, Lika county, in the Austrian Empire (present day Croatia), on 10 July [O.S. 28 June] 1856."]

或查询Where Nikola Tesla born?/Where Nikola Tesla raised?并获得:

“在奥地利帝国出生和长大,特斯拉得到了……”?

提前致谢。

4

1 回答 1

0

邻近搜索查找彼此之间特定距离内的术语。

要执行邻近搜索,请将波浪号字符 ~ 和一个数值添加到搜索短语的末尾。例如,要在文档中搜索彼此相距 10 个字以内的“apache”和“jakarta”,请使用以下搜索:

"jakarta apache"~10

这里提到的距离是匹配指定短语所需的术语移动次数。在上面的示例中,如果“apache”和“jakarta”在一个字段中相隔 10 个空格,但“apache”出现在“jakarta”之前,则需要移动 10 多个术语才能将术语移动到一起并将“apache”定位到"jakarta" 的右边,中间有一个空格。

您也可以在您的情况下尝试邻近搜索,如下所示。

text:"Nikola Tesla born?"~10

text:"Austrian Empire engineering"~10

text:"Tesla born?"~10

请参考 solr 管理工具中的图像。

为了text:"Nikola Tesla born?"~10

Solr分析1

为了text:"Austrian Empire engineering"~10

Solr分析2

对于text:"Tesla born?"~10查询去"http://localhost:8983/solr/TestCore/select?q=text:"Tesla born?"~10"

Solr分析3

于 2019-05-24T11:46:26.887 回答