我是solr的新手,正在尝试建立一个问答系统。 我已经索引了一些维基百科页面,例如Nikola Tesla。 https://en.wikipedia.org/wiki/Nikola_Tesla
我的问题是:在Solr中是否可以以及如何将查询作为问题输入?
我按“目录”(对应于SectionTitle)拆分了Wikipedia页面,因此...对于查询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?
并获得:
“特斯拉在奥地利帝国出生并长大……”?
谢谢。
答案 0 :(得分:0)
邻近搜索可查找特定距离内的字词 彼此。
要执行邻近搜索,请添加波浪号〜和一个数字 值到搜索词组的末尾。例如,搜索 在文档中彼此不超过10个字的“ apache”和“ jakarta”, 使用搜索:
import React from 'react'; import './App.css'; import {Button} from 'react-bootstrap' class App extends React.Component { constructor() { super(); this.handleClick = this.handleClick.bind(this); } handleClick(){ var stripe = Stripe('pk_test_XXXXXXXXXXXX'); // I will use stripe variable later. But for now I have an error with previous line } render() { return( <div> <Button className= "btn-xlBook" variant="primary" onClick={this.handleClick}> OK </Button> </div> ) } } export default App
此处所指的距离是所需术语移动的数量 匹配指定的词组。在上面的示例中,如果“ apache”和 “雅加达”在一个领域中相隔10个空格,但“阿帕奇”出现了 在“雅加达”之前,需要进行十次以上的学期变动 一起移动条款并将“ apache”定位在 “雅加达”之间有一个空格。
您也可以按照以下情况尝试进行邻近搜索。
"jakarta apache"~10
请参考solr管理工具中的图像。
对于text:"Nikola Tesla born?"~10
text:"Austrian Empire engineering"~10
text:"Tesla born?"~10
对于text:"Nikola Tesla born?"~10
对于text:"Austrian Empire engineering"~10
,查询按text:"Tesla born?"~10