[ 
https://issues.apache.org/jira/browse/SOLR-11149?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16102790#comment-16102790
 ] 

Joe Yang edited comment on SOLR-11149 at 7/27/17 6:54 AM:
----------------------------------------------------------

[~erickerickson] thanks for your comment: it did solve my issue by your 
suggestion, but the output is slightly weird, any advice would be appreciated...
My data-config.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource name="fromMysql"
                  type="JdbcDataSource"
                  driver="com.mysql.jdbc.Driver"
                  url="jdbc:mysql://192.168.112.164:3306/db_virtualbusiness"
                  user="root"
                  password="admin123"/>
<document>
        <entity name="tb_ship" query="SELECT ship_id, deliver_to FROM tb_ship">
                 <field column="ship_id" name="id"/>
                 <field column="deliver_to" name="deliver_to"/>
        </entity>
</document>
</dataConfig>

My managed-schema:
 <field name="id" type="string" multiValued="false" indexed="true" 
required="true" stored="true"/>
  <field name="deliver_to" type="string" indexed="true" stored="true" 
required="true" multiValued="false" />

My solr query turned out to be as follows, I think we should have some index 
key words instead of a phrase ?
{
  "responseHeader": {
    "status": 0,
    "QTime": 0,
    "params": {
      "q": "*:*",
      "indent": "true",
      "wt": "json",
      "_": "1501137226686"
    }
  },
  "response": {
    "numFound": 96,
    "start": 0,
    "docs": [
      {
        "deliver_to": "722 台南市 佳里區 佳化里2號",
        "id": "39e444f9-71b0-11e7-af5d-005056af8f8b",
        "_version_": 1574038831874703400
      },
      {
        "deliver_to": "428 台中市 大雅區 仁愛路105號",
        "id": "39e46288-71b0-11e7-af5d-005056af8f8b",
        "_version_": 1574038831876800500
      },
      {
        "deliver_to": "桃園市蘆竹區仁和街153號1樓",
        "id": "39e47554-71b0-11e7-af5d-005056af8f8b",
        "_version_": 1574038831877849000
      },
      {
        "deliver_to": "",
        "id": "39e489b5-71b0-11e7-af5d-005056af8f8b",
        "_version_": 1574038831877849000


was (Author: vkjuju):
[~erickerickson] thanks for your comment: it did solve my issue by your 
suggestion, but the output is slightly weird:
My data-config.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource name="fromMysql"
                  type="JdbcDataSource"
                  driver="com.mysql.jdbc.Driver"
                  url="jdbc:mysql://192.168.112.164:3306/db_virtualbusiness"
                  user="root"
                  password="admin123"/>
<document>
        <entity name="tb_ship" query="SELECT ship_id, deliver_to FROM tb_ship">
                 <field column="ship_id" name="id"/>
                 <field column="deliver_to" name="deliver_to"/>
        </entity>
</document>
</dataConfig>

My managed-schema:
 <field name="id" type="string" multiValued="false" indexed="true" 
required="true" stored="true"/>
  <field name="deliver_to" type="string" indexed="true" stored="true" 
required="true" multiValued="false" />

My solr query turned out to be as follows, I think we should have some index 
key words instead of a phrase ?
{
  "responseHeader": {
    "status": 0,
    "QTime": 0,
    "params": {
      "q": "*:*",
      "indent": "true",
      "wt": "json",
      "_": "1501137226686"
    }
  },
  "response": {
    "numFound": 96,
    "start": 0,
    "docs": [
      {
        "deliver_to": "722 台南市 佳里區 佳化里2號",
        "id": "39e444f9-71b0-11e7-af5d-005056af8f8b",
        "_version_": 1574038831874703400
      },
      {
        "deliver_to": "428 台中市 大雅區 仁愛路105號",
        "id": "39e46288-71b0-11e7-af5d-005056af8f8b",
        "_version_": 1574038831876800500
      },
      {
        "deliver_to": "桃園市蘆竹區仁和街153號1樓",
        "id": "39e47554-71b0-11e7-af5d-005056af8f8b",
        "_version_": 1574038831877849000
      },
      {
        "deliver_to": "",
        "id": "39e489b5-71b0-11e7-af5d-005056af8f8b",
        "_version_": 1574038831877849000

> import data from mysql failed
> -----------------------------
>
>                 Key: SOLR-11149
>                 URL: https://issues.apache.org/jira/browse/SOLR-11149
>             Project: Solr
>          Issue Type: Test
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: Build
>    Affects Versions: 5.5.4
>         Environment: ubuntu14.04+solr5.5.4+mysql5.7.15
>            Reporter: Joe Yang
>
> dataimport from mysql to solr, errors as follows:
> 2017-07-26 10:01:49.020 WARN  (Thread-47) [   x:mycore1] o.a.s.h.d.SolrWriter 
> Error creating document : SolrInputDocument(fields: 
> [deliver_to=桃園市桃園區大興路118-1號4樓, ship_id=fd219e30-7119-11e7-af5d-005056af8f8b])
> org.apache.solr.common.SolrException: Document is missing mandatory uniqueKey 
> field: id
>         at 
> org.apache.solr.update.AddUpdateCommand.getIndexedId(AddUpdateCommand.java:97)
>         at 
> org.apache.solr.update.processor.DistributedUpdateProcessor.versionAdd(DistributedUpdateProcessor.java:947)
>         at 
> org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:712)
>         at 
> org.apache.solr.update.processor.LogUpdateProcessorFactory$LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:103)
>         at 
> org.apache.solr.handler.dataimport.SolrWriter.upload(SolrWriter.java:74)
>         at 
> org.apache.solr.handler.dataimport.DataImportHandler$1.upload(DataImportHandler.java:260)
>         at 
> org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:524)
>         at 
> org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:414)
>         at 
> org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:329)
>         at 
> org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:232)
>         at 
> org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:416)
>         at 
> org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:480)
>         at 
> org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:461)



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to