Maybe the id values overlap between your database tables. Solr needs unique
values for the id, so if a document is indexed from a different database
table but the same id value, Solr will replace the existing document with
that id. You need to make sure that the id values are unique across all of
your database tables, such as adding a prefix or suffix that identifies the
database table the data is coming from.
In other words, maybe all of your "journal" documents got overwritten with
documents with the same ids from other tables.
-- Jack Krupansky
-----Original Message-----
From: anarchos78
Sent: Friday, May 11, 2012 7:47 AM
To: solr-user@lucene.apache.org
Subject: Indexing data from database
Hello friends,
I am trying to index data from database. I am doing that successfully. But I
have a problem. I want to use one index for whole database. All the db
tables have at least 3 columns with the same name (I want to be like this).
For instance I have these tables: members, new_members, books, journals and
cds. All these have columns named: id, model, biog. So, in all the db tables
the id (auto incremented) starts from 1.
When I am querying Solr using filter (fq=model:journal) it is returning
nothing. Querying for books returns a portion of data (I have 5 rows and it
returns 2. I am using *:* in order to retrieve all the rows ). I know that
the data is in Solr’s “data” file. I think there is a conflict of some kind.
How can I have a single index with all these tables without any conflicts?
*The data-config.xml:*
<?xml version="1.0" encoding="utf-8"?>
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/rental"
user="root"
password="1a2b3c4d"/>
<document>
<entity name="members" pk="id" transformer="HTMLStripTransformer"
query="select id, firstname, lastname, biog, model from members">
<field column="id" name="id" />
<field column="firstname" name="firstname" stripHTML="true" />
<field column="lastname" name="lastname" stripHTML="true" />
<field column="biog" name="biog" stripHTML="true" />
<field column="model" name="model" stripHTML="true" />
</entity>
<entity name="new_members" pk="id" transformer="HTMLStripTransformer"
query="select id, firstname, lastname, biog, model from new_members">
<field column="id" name="id" />
<field column="firstname" name="firstname" stripHTML="true" />
<field column="lastname" name="lastname" stripHTML="true" />
<field column="biog" name="biog" stripHTML="true" />
<field column="model" name="model" stripHTML="true" />
</entity>
<entity name="books" pk="id" transformer="HTMLStripTransformer"
query="select id, title, description, model from books">
<field column="id" name="id" />
<field column="title" name="title" stripHTML="true" />
<field column="description" name="biog" stripHTML="true" />
<field column="model" name="model" stripHTML="true" />
</entity>
<entity name="journals" pk="id" transformer="HTMLStripTransformer"
query="select id, title, description, model from journals">
<field column="id" name="id" />
<field column="title" name="title" stripHTML="true" />
<field column="description" name="biog" stripHTML="true" />
<field column="model" name="model" stripHTML="true" />
</entity>
<entity name="cds" pk="id" transformer="HTMLStripTransformer"
query="select id, title, description, model from cd">
<field column="id" name="id" />
<field column="title" name="title" stripHTML="true" />
<field column="description" name="biog" stripHTML="true" />
<field column="model" name="model" stripHTML="true" />
</entity>
</document>
</dataConfig>
*The schema.xml (fields):*
<fields>
<field name="id" type="string" indexed="true" stored="true" />
<field name="model" type="text_en" indexed="true" stored="true" />
<field name="firstname" type="text_en" indexed="true" stored="true"/>
<field name="lastname" type="text_en" indexed="true" stored="true"/>
<field name="title" type="text_en" indexed="true" stored="true"/>
<field name="biog" type="text_en" indexed="true" stored="true"/>
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField> biog </defaultSearchField>
--
View this message in context:
http://lucene.472066.n3.nabble.com/Indexing-data-from-database-tp3979692.html
Sent from the Solr - User mailing list archive at Nabble.com.