简体   繁体   English

Solr没有索引MySQL数据库

[英]Solr is not indexing mysql database

Hi Am trying to index mysql db to solr. 嗨,我正在尝试将mysql db索引到solr。 But its only indexing id. 但它唯一的索引ID。 I tried a lot. 我试了很多 But no success. 但是没有成功。 But I tried to index geo location in the same db for testing and its indexing all the cities successfully. 但是我尝试为同一数据库中的地理位置建立索引以进行测试,并成功为所有城市建立索引。 I just what to know what am missing. 我只是知道什么丢失了。 This query contains some descriptions of the products like "Solr not returning results indexed from MySQL". 该查询包含对产品的一些描述,例如“ Solr不返回从MySQL索引的结果”。

My db config 我的数据库配置

    <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>

Schema 架构图

<?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>

Result 结果

{
  "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}]
  }}

Debug 除错

{
  "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"
  }
}

Finally I found the issue for this solr. 终于,我找到了这个solr的问题。

Am using solr 6.6 So I've to rename managed-schema to schema as per this tutorial in this link http://makble.com/how-to-index-mysql-data-in-solr . 我正在使用solr 6.6,因此我必须根据此链接http://makble.com/how-to-index-mysql-data-in-solr中的本教程,将托管模式重命名为架构。 Also I made a test run with geo cities. 我还对地理城市进行了测试。 By default it took managed schema as main schema it took my old test schema fields. 默认情况下,它将托管架构作为主要架构,将旧测试架构字段作为主体。 Its not getting schema.xml. 它没有得到schema.xml。

So the solution is need to define schema.xml 所以解决方案是需要定义schema.xml

<schemaFactory class="ClassicIndexSchemaFactory"/>

Reference link : Data-config.xml and mysql - I can load only "id" column 参考链接: Data-config.xml和mysql-我只能加载“ id”列

or rename managed-schema to schema.xml or delete managed-schema 或将托管模式重命名为schema.xml或删除托管模式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM