2015-04-07 11 views
5

Ho Solr 5.0.0 su Windows Server 2012. Vorrei caricare tutti i dati dalla mia tabella in solr engine.Data-config.xml e mysql - Posso solo caricare la colonna "id"

miei dati-config.xml si presenta così:

<?xml version="1.0" encoding="UTF-8" ?> 
<!--# define data source --> 
<dataConfig> 
<dataSource type="JdbcDataSource" 
     driver="com.mysql.jdbc.Driver" 
     url="jdbc:mysql://localhost:3306/database" 
     user="root" 
     password="root"/> 
<document> 
<entity name="my_table" 
pk="id" 
query="SELECT ID, LASTNAME FROM my_table limit 2"> 
<field column="ID" name="id" type="string" indexed="true" stored="true" required="true" /> 
<field column="LASTNAME" name="lastname" type="string" indexed="true" stored="true"/> 
</entity> 
</document> 
</dataConfig> 

quando scelgo dataimport, ho ottenuto una risposta:

Indexing completed. Added/Updated: 2 documents. Deleted 0 documents  
Requests: 1, Fetched: 2, Skipped: 0, Processed: 2 

And Raw Debug-Response:

{ 
    "responseHeader": { 
    "status": 0, 
    "QTime": 280 
    }, 
    "initArgs": [ 
    "defaults", 
    [ 
     "config", 
     "data-config.xml" 
    ] 
    ], 
    "command": "full-import", 
    "mode": "debug", 
    "documents": [ 
    { 
     "id": [ 
     1983 
     ], 
     "_version_": [ 
     1497798459776827400 
     ] 
    }, 
    { 
     "id": [ 
     1984 
     ], 
     "_version_": [ 
     1497798459776827400 
     ] 
    } 
    ], 
    "verbose-output": [ 
    "entity:my_table", 
    [ 
     "document#1", 
     [ 
     "query", 
     "SELECT ID,LASTNAME FROM my_table limit 2", 
     "time-taken", 
     "0:0:0.8", 
     null, 
     "----------- row #1-------------", 
     "LASTNAME", 
     "Gates", 
     "ID", 
     1983, 
     null, 
     "---------------------------------------------" 
     ], 
     "document#2", 
     [ 
     null, 
     "----------- row #1-------------", 
     "LASTNAME", 
     "Doe", 
     "ID", 
     1984, 
     null, 
     "---------------------------------------------" 
     ], 
     "document#3", 
     [] 
    ] 
    ], 
    "status": "idle", 
    "importResponse": "", 
    "statusMessages": { 
    "Total Requests made to DataSource": "1", 
    "Total Rows Fetched": "2", 
    "Total Documents Skipped": "0", 
    "Full Dump Started": "2015-04-07 15:05:22", 
    "": "Indexing completed. Added/Updated: 2 documents. Deleted 0 documents.", 
    "Committed": "2015-04-07 15:05:22", 
    "Optimized": "2015-04-07 15:05:22", 
    "Total Documents Processed": "2", 
    "Time taken": "0:0:0.270" 
    } 
} 

E infine quando sto interrogando Solr

http://localhost:8983/solr/test/query?q=*:* 

ho una risposta:

{ 
    "responseHeader":{ 
    "status":0, 
    "QTime":0, 
    "params":{ 
     "q":"*:*"}}, 
    "response":{"numFound":2,"start":0,"docs":[ 
     { 
     "id":"1983", 
     "_version_":1497798459776827392}, 
     { 
     "id":"1984", 
     "_version_":1497798459776827393}] 
    }} 

vorrei vedi colonna cognome troppo. Perché non posso?

+0

Inserisci schema.xml – arun

+0

Sembra che si sta cercando di definire i campi come si farebbe normalmente nel schema.xml' direttamente 'in' data-config.xml', che dovrei sperimentare, ma non credo sia effettivamente possibile. L'elemento '' in' data-config.xml' è più relativo al mapping della 'colonna' SQL restituita con il nome Solr del campo' '' previsto. Stai definendo un campo 'lastname' in' schema.xml'? L'importatore di dati di solito interrompe automaticamente i campi restituiti dalle query se non sono mappati su campi definiti. – frances

+0

Grazie per le risposte! Quindi: 1. I dati modificati-config.xml a: \t ' \t \t \t \t \t ' 2. E ha aggiunto linea ' ' Il mio schema.xml ha l'aspetto seguente: http: //pastebin.com/xLgsv31h –

risposta

12

Tale avviso nei registri è in realtà il vero problema.

Se si guarda nel file solrconfig.xml si avrà una sezione:

<schemaFactory class="ManagedIndexSchemaFactory"> 
    <bool name="mutable">true</bool> 
    <str name="managedSchemaResourceName">managed-schema</str> 
</schemaFactory> 

Ciò significa che il file schema.xml viene ignorato. Verrà utilizzato lo schema gestito del file nella stessa cartella.

Ci sono un paio di modi per risolvere questo. È possibile commentare la sezione dello schema gestito e sostituirla con

<schemaFactory class="ClassicIndexSchemaFactory"/> 

In alternativa, è possibile eliminare il file dello schema gestito. SOLR leggerà quindi il file schema.xml al riavvio e genererà un nuovo schema gestito. Se funziona, dovresti vedere i tuoi campi nella parte inferiore del file.

Per maggiori informazioni si prega di consultare:

https://cwiki.apache.org/confluence/display/solr/Managed+Schema+Definition+in+SolrConfig

Problemi correlati