如何向solr查询响应添加新参数

时间:2017-05-17 08:05:39

标签: mysql solr lucene

我正在尝试运行以下网址

http://localhost:8983/solr/collection1/select?q=reqst00548008&fl=trendid,keywords,problem,general&sort=score+desc&debug=query&wt=json&indent=true&hl=true&hl.fl=keywords,problem,symptom,general&hl

我得到的回复如下

{
  "responseHeader":{
    "status":0,
    "QTime":1,
    "params":{
      "q":"reqst00548008",
      "debug":"query",
      "hl":["true",
        ""],
      "indent":"true",
      "fl":"trendid,keywords,problem,general",
      "sort":"score desc",
      "hl.fl":"keywords,problem,symptom,general",
      "wt":"json"}},
  "response":{"numFound":1,"start":0,"docs":[
      {
        "general":"NullPointerException seen in logs",
        "keywords":"NPE, NullPointerException",
        "trendid":"2064"}]
  },
  "highlighting":{
    "2064":{}},
  "debug":{
    "rawquerystring":"reqst00548008",
    "querystring":"reqst00548008",
    "parsedquery":"text:reqst00548008",
    "parsedquery_toString":"text:reqst00548008",
    "QParser":"LuceneQParser"}
}

我想在回复中包含问题而我无法做到。

到目前为止我尝试将其添加到data-config.xml中,如下所示

<dataConfig> 
    <dataSource type="JdbcDataSource"
   driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
   url="jdbc:sqlserver://127.0.0.1\SQLEXPRESS;databaseName=sustainingxxxx"
   user="max"
   password="xxxxxx"/>

    <document name="content">
        <entity name="id"
query="select id,createtime,lastmodified,modifiedby,title,keywords,general,symptom,diagnosis,resolution,problem FROM trends"
deltaImportQuery="select id,createtime,lastmodified,modifiedby,title,keywords,general,symptom,diagnosis,resolution,problem FROM trends WHERE id = ${dataimporter.delta.id}"
deltaQuery="select id FROM trends WHERE lastmodified > '${dataimporter.last_index_time}' or createtime > '${dataimporter.last_index_time}'">

            <field column="id" name="trendid" />
            <field column="lastmodified" name="lastmodified" />
            <field column="modifiedby" name="modifiedby" />
            <field column="title" name="title" />
            <field column="keywords" name="keywords" />
            <field column="general" name="general" />
            <field column="symptom" name="symptom" />
            <field column="diagnosis" name="diagnosis" />
            <field column="resolution" name="resolution" />
            <field column="problem" name="problem" />
        </entity>
    </document>
</dataConfig>

我添加了所有问题,但这没有帮助。我还需要提一下其他地方吗?我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

problem文件中不存在schema.xml字段,这是您在查询结果中看不到的原因。

<field name="trendid" type="string" indexed="true" stored="true" required="true"/>
<field name="lastmodified" type="date" indexed="true" stored="true"/>
<field name="modifiedby" type="string" indexed="true" stored="true" />
<field name="title" type="text_en" indexed="true" stored="true"/>
<field name="keywords" type="text_en" indexed="true" stored="true"/>
<field name="general" type="text_en" indexed="true" stored="true"/>
<field name="symptom" type="text_en" indexed="true" stored="true"/>
<field name="diagnosis" type="text_en" indexed="true" stored="true"/>
<field name="resolution" type="text_en" indexed="true" stored="true"/>

您必须在架构中添加该字段,如果您没有特定的文本分析需求,只需添加:

<field name="problem" type="string" indexed="true" stored="true" required="true"/>

因此,您可以重新加载核心配置或重新启动Solr实例。

然后您将数据重新加载到索引中。