【问题标题】:Solr is not indexing mysql databaseSolr 没有索引 mysql 数据库
【发布时间】:2017-09-25 20:27:48
【问题描述】:

您好我正在尝试将 mysql db 索引到 solr。但它唯一的索引ID。我尝试了很多。但没有成功。但是我尝试在同一个数据库中索引地理位置以进行测试并成功索引所有城市。我只是知道缺少什么。此查询包含对产品的一些描述,例如“Solr 未返回从 MySQL 索引的结果”。

我的数据库配置

    <entity name="geo"  
    pk="id"
    query="select id, title from `inlive`"
    deltaImportQuery="select id, title from `inlive`"
    deltaQuery="select id, title from `inlive`"
    >
        <field column="id" name="id"/>
        <field column="title" name="title"/>
  </entity>

架构

<?xml version="1.0" encoding="UTF-8" ?>
<uniqueKey>id</uniqueKey>
<schema name="geo" version="1.5">
    <field name="_version_" type="long" indexed="true" stored="true"/>
    <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> 
    <field name="title" type="string" indexed="true" stored="true" multiValued="false" required="true" />
</schema>

结果

{
  "responseHeader":{
    "status":0,
    "QTime":3,
    "params":{
      "q":"*:*",
      "indent":"on",
      "wt":"json",
      "_":"1506369405758"}},
  "response":{"numFound":2,"start":0,"docs":[
      {
        "id":"1",
        "_version_":1579543508130201600},
      {
        "id":"2",
        "_version_":1579543508218281984}]
  }}

调试

{
  "responseHeader": {
    "status": 0,
    "QTime": 275
  },
  "initArgs": [
    "defaults",
    [
      "config",
      "data-config.xml"
    ]
  ],
  "command": "full-import",
  "mode": "debug",
  "documents": [
    {
      "id": [
        1
      ],
      "_version_": [
        1579544391043776500
      ]
    },
    {
      "id": [
        2
      ],
      "_version_": [
        1579544391046922200
      ]
    }
  ],
  "verbose-output": [
    "entity:geo",
    [
      "document#1",
      [
        "query",
        "select id, title from `inlive`",
        "time-taken",
        "0:0:0.10",
        null,
        "----------- row #1-------------",
        "id",
        1,
        "title",
        "test title",
        null,
        "---------------------------------------------"
      ],
      "document#2",
      [
        null,
        "----------- row #1-------------",
        "id",
        2,
        "title",
        "test title 2",
        null,
        "---------------------------------------------"
      ],
      "document#3",
      []
    ]
  ],
  "status": "idle",
  "importResponse": "",
  "statusMessages": {
    "Total Requests made to DataSource": "1",
    "Total Rows Fetched": "2",
    "Total Documents Processed": "2",
    "Total Documents Skipped": "0",
    "Full Dump Started": "2017-09-25 20:21:57",
    "": "Indexing completed. Added/Updated: 2 documents. Deleted 0 documents.",
    "Committed": "2017-09-25 20:21:57",
    "Optimized": "2017-09-25 20:21:57",
    "Time taken": "0:0:0.255"
  }
}

【问题讨论】:

  • 您缺少entity 结束标签,您是否确定在更改配置后重新加载配置?
  • 实体结束标签已存在于此。代码编辑器错过了结束标记。知道缺少什么吗?
  • 我发现了问题。当我使用 它的索引。但我需要用标题属性对其进行索引。
  • 听起来您没有在问题中添加的架构,而是默认架构 - 您是否在更改架构后重新加载了核心或重新启动了 Solr?
  • 是的。我添加了架构。但它以托管模式为主。并在日志记录中显示警告。然后只有我能找到问题。我为此发布了详细的答案。现在它工作得很好。

标签: mysql solr solrcloud


【解决方案1】:

我终于找到了这个 solr 的问题。

我正在使用 solr 6.6 因此,我必须按照此链接http://makble.com/how-to-index-mysql-data-in-solr 中的本教程将托管模式重命名为模式。我还对地理城市进行了测试。默认情况下,它采用托管模式作为主模式,它采用了我的旧测试模式字段。它没有得到 schema.xml。

所以解决方案是需要定义schema.xml

<schemaFactory class="ClassicIndexSchemaFactory"/>

参考链接:Data-config.xml and mysql - I can load only "id" column

或将托管模式重命名为 schema.xml 或删除托管模式

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-08
    • 2014-07-07
    • 2010-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-25
    • 2017-10-21
    相关资源
    最近更新 更多